Android Implicit, Explicit Intent & Type of Intent with Examples

Implicit Intent and Explicit Intent is a type of Intent in Android. The intent is the main component of Android app development. The intent is the medium to pass between components such as activities, content providers, broadcast receivers, services etc.

Some use case of Intent is :

  • Start the service
  • Launch an activity
  • Display a web page
  • Broadcast a message
  • Dial a phone call.
  • Map GEO location

 

Implicit Intent

Implicit Intent doesn’t specify the component in the app. In such a case, intent provides information on available components provided by the system that is to be invoked.

Implicit intent example: A button on click of which you will redirect to a web page. If your Device has multiple browsers then option popup (bottom sheet) will open and show them all.

 

Explicit Intent

Explicit intent specifies the component in an application, that is which class to be invoked. You can pass the information from one activity to another using explicit intent.

Explicit intent example: On click button go to another Activity. As a definition, we know about the target component.

For much better understanding, you should read “Intent Filters in Android” and “What is Android Intent“.

 

Let’s Build an App for Implicit intent and Explicit intent :

 

Step 1. Create a new project “Build Your First Android App in Kotlin
Step 2. Create a new Activity ” SecondActivity.class ” for an Explication intent example

Add the following code in “activity_second.xml” res layout file

Now add code in SecondActivity.class and set resource layout file.

Step 3. Add Buttons widget in an activity_main.xml resource file

One button for Implicit intent and another one for Explicit intent example.

Step 3. Add the following code in MainActivity.class

In this code using 2 buttons, Where you can see for Explicit intent in btn_Explicit, its very easy just pass the intent to target component.

And Implicit intent in btn_Implicit used <action> and <data> ,

Step 6. Run the application, in an emulator or On you android device
Output screenshot Android Implicit and Explicit Intent example :

 

Types of Intent - Implicit and Explicit Intent in Android example output

Video Output

Download source code Android Implicit and Explicit Intent

https://github.com/EyeHunts/IntentTypesImplicitAndExplicit

 

Note : This example (Project) is developed in Android Studio 3.1.3 . Tested on Android 9 ( Android-P), compile SDK version API 26: Android 8.0 (Oreo)

MinSdkVersion=”15″

TargetSdkVersion=”27″

Coding in Java


Bonus : 


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.