Best Division

Spread Your Knowledge

  • All topics
  • About us
  • Contact us
  • Privacy policy
  • Terms of service
  • Copyright
  • Facebook
  • Twitter
  • Instagram
  • Youtube
  • LinkedIn
  • Pinterest
  • Github
  • Tumblr

© 2026 Best Division

How Do Explicit Intents Start Another Screen in Android?

Android
Jayant Kumar
Jayant Kumar@jayantkumar314
PublishedNov 29, 2026
6 min read

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.

Table of Contents

  • Starting another Activity with an explicit intent
  • Passing data with extras
  • Passing custom objects with Parcelable
  • Getting a result back from the second screen
  • Explicit versus implicit intents
  • Common pitfalls
  • Frequently Asked Questions
    • How do I go back to the previous screen?
    • Can I use an explicit intent to open another app?
    • Why is my extra always null or the default?
    • Is it better to use Navigation instead of intents?
  • Summary
  • Related Articles

Starting another Activity with an explicit intent

An Intent is a message object. For an explicit intent you give it a Context and the target class:

kotlin

The target must be declared in AndroidManifest.xml:

xml

exported="false" is the right setting for screens that only your own app opens. Without the manifest entry, the call throws ActivityNotFoundException.

Passing data with extras

An intent can carry small values in a Bundle of key and value pairs, called extras:

kotlin
kotlin

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:

kotlin

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.

Passing custom objects with Parcelable

To send your own class, make it Parcelable. The Kotlin Parcelize plugin writes the boilerplate:

kotlin
kotlin

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.

Getting a result back from the second screen

The old startActivityForResult and onActivityResult are deprecated. Use the Activity Result API, which is lifecycle-aware and type-safe:

kotlin

The second Activity sets its result and closes:

kotlin

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 versus implicit intents

Explicit intentImplicit intent
TargetA named component classAn action and data, such as ACTION_VIEW with a URL
Resolved byYouThe system, which matches intent filters
Typical useScreens inside your own appOpen a web page, share text, dial a number
SecuritySafe, since it only reaches the named classCan 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.

Common pitfalls

  • Forgetting to declare the target Activity in the manifest.
  • Casting extras with the wrong getter, which silently returns the default value, for example getIntExtra on a string key returns -1.
  • Sending large objects in extras, which can throw TransactionTooLargeException.
  • Calling startActivity with an application context without FLAG_ACTIVITY_NEW_TASK, which fails.
  • Mutating the original intent when you need a fresh one for each launch.

Frequently Asked Questions

How do I go back to the previous screen?

Call finish() in the second Activity, or let the user press Back. The system returns to the previous Activity in the back stack.

Can I use an explicit intent to open another app?

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.

Why is my extra always null or the default?

The key names differ between sender and receiver, or you used the wrong getter type. Use shared constants and match the type.

Is it better to use Navigation instead of intents?

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.

Summary

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.

Related Articles

  • Android Activity Lifecycle Explained with Kotlin and Java Examples
  • What are implicit intents in Android and how do they work?
  • Learn Android: Complete Study Roadmap from Beginner to Advanced
Share