An explicit intent starts a specific component by naming its class, which is how you open another screen inside your own app. You build it with Intent(this, DetailActivity::class.java) and pass it to startActivity(). Because you name the exact target, the system does not have to search for a matching app, so this is the standard way to move between your own Activities.
The android explicit intent is the counterpart of an implicit intent, which only describes an action and lets the system pick a handler.
An Intent is a message object. For an explicit intent you give it a Context and the target class:
The target must be declared in AndroidManifest.xml:
exported="false" is the right setting for screens that only your own app opens. Without the manifest entry, the call throws ActivityNotFoundException.
An intent can carry small values in a Bundle of key and value pairs, called extras:
Define key names as constants, prefixed with your package, so sender and receiver cannot disagree. A cleaner approach is to expose a function that builds the intent, so callers never touch the keys:
Extras are limited by the Binder transaction size, about 1 MB shared across all transactions in the process, so pass an id and load the full data in the new screen instead of sending big lists or bitmaps.
To send your own class, make it Parcelable. The Kotlin Parcelize plugin writes the boilerplate:
The typed getParcelableExtra(name, Class) overload arrived in API 33 and the one-argument form is deprecated, so use the version check shown. BundleCompat.getParcelable from AndroidX can hide that check for you.
The old startActivityForResult and onActivityResult are deprecated. Use the Activity Result API, which is lifecycle-aware and type-safe:
The second Activity sets its result and closes:
Register the launcher as a property or in onCreate, never inside a click listener, because registration must happen before the Activity reaches the started state.
| Explicit intent | Implicit intent | |
|---|---|---|
| Target | A named component class | An action and data, such as ACTION_VIEW with a URL |
| Resolved by | You | The system, which matches intent filters |
| Typical use | Screens inside your own app | Open a web page, share text, dial a number |
| Security | Safe, since it only reaches the named class | Can reach any matching app |
For starting your own services and receivers you should always use explicit intents. Since Android 5.0 (API 21), binding to a Service with an implicit intent throws an exception.
getIntExtra on a string key returns -1.TransactionTooLargeException.startActivity with an application context without FLAG_ACTIVITY_NEW_TASK, which fails.Call finish() in the second Activity, or let the user press Back. The system returns to the previous Activity in the back stack.
Yes, if you know its package and class name, with setClassName or setComponent. The target must be exported, and on Android 11 and higher you need package visibility declarations, so an implicit intent is usually the better choice.
The key names differ between sender and receiver, or you used the wrong getter type. Use shared constants and match the type.
For screens inside one app, Jetpack Navigation with Compose or Fragments is the modern recommendation. Explicit intents are still the right tool for separate Activities and for starting Services.
An explicit intent names the target class, so startActivity(Intent(this, DetailActivity::class.java)) opens a screen of your own app. Declare the Activity in the manifest, pass small data in extras or Parcelable objects, and use the Activity Result API for results. Keep implicit intents for asking other apps to do something.