android-studio
  1. android-studio-explicit-intent

Android Studio Explicit Intent

An explicit Intent is a user-defined intent, where the developer explicitly specifies the component to use to fulfill the intent. An intent is used to navigate between different screens or activities in android applications.

Syntax

Intent intent = new Intent(context, targetActivity.class);
startActivity(intent);

Example

// Declare Explicit Intent
Intent intent = new Intent(MainActivity.this, SecondActivity.class);

// Start Second Activity
startActivity(intent);

Output

The output of explicit intent will be the second activity that is started by calling startActivity() method.

Explanation

Explicit intent specifies the name of the target activity directly in the Intent object. The target activity is resolved by the package and class name passed as parameters to the Intent constructor. This type of intent is used to launch a specific activity from the current activity.

Use

Explicit intents are used to launch an activity within the same application or launch an activity in another application by specifying the package name.

Important Points

  • An explicit intent explicitly defines the target component to be invoked.
  • Explicit intent is used to launch a specific activity from the current activity.
  • Components of explicit intent are known at compile-time.
  • Explicit Intent is used when either there is an activity defined in your app, or if there is an activity in another app that does not require any permission.

Summary

In summary, explicit intent is used to invoke a specific component within an application or the component of another application that does not require any permission. It is commonly used to navigate between different screens or activities in android applications.

Published on: