Javatpoint Logo
Javatpoint Logo

Kotlin Android Explicit Intent

Android Intent is a messaging object used to request another app component to perform an action. Intent facilitates users to communicate with app component through several ways such as starting an activity, starting a service, delivering a broadcast receiver, etc.

Android intents are mainly used to:

  • Start the service
  • Launch an activity
  • Display a web page
  • Display a list of contacts
  • Broadcast a message
  • Dial a phone call etc.

Types of Android Intents

There are two types of intent in Android:

Explicit Intent: This intent satisfies the request within the application component. It takes the fully qualified class name of activities or services that we want to start.

Implicit Intent: This intent does not specify the component name. It invokes the component of another app to handle it.

Kotlin Android Explicit Intent Example

In this example, we will call the other activity class from another activity class using explicit intent. Using intent, we will send the data from the first activity class to second activity class. Second activity class gets this data and displays them in toast message.

Kotlin Android Explicit Intent


Add the following code in the activity_main.xml.


Add the following code in the MainActivity.kt class. In this class, we are creating an instance of Intent class and calling the component activity class SecondActivity.kt. The putExtra(key, value) method of Intent class send the data to the SecondActivity.kt class. The startActivity() method starts the Intent.

Create another activity class named as SecondActivity.


In the second_activity.xml file add the following code.


Add the following code in the SecondActivity.kt class. In this class, we are receiving the intent data using creating the instance on Bundle class using intent.extras and displaying the data in toast message. By clicking on the button, we are invoking Intent to call MainActivity.kt class.


Kotlin Android Explicit Intent Kotlin Android Explicit Intent
Next Topic#

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA