Intents & Deep Linking Interview Questions
ANDROID › Components
What is the difference between an explicit and an implicit intent?
What a strong answer covers: An explicit intent names the target component class, used within your own app. An implicit intent declares an action and data (ACTION_VIEW with a URL, ACTION_SEND), and the system finds apps whose intent filters match, showing a chooser if several do. Since Android 11, you may need queries in the manifest to see which apps can handle an implicit intent.
What is a PendingIntent, and why do you have to choose FLAG_IMMUTABLE or FLAG_MUTABLE?
What a strong answer covers: A PendingIntent is a token that lets another app or the system (notifications, alarms, widgets) send an intent later with your app's identity and permissions. Since Android 12, you must say whether it's immutable or mutable. Immutable is safer because the receiver can't change the intent; mutable is needed only when the receiver must fill in extras, like inline reply or bubbles.
What's the difference between deep links and Android App Links?
What a strong answer covers: A deep link is any intent filter for a URI, custom scheme or http, which can trigger a disambiguation dialog and can be claimed by any app. App Links are verified http/https links: you host assetlinks.json on your domain, Android verifies ownership, and links open your app directly. Since Android 12, unverified web links open in the browser by default.
What are launch modes and intent flags like singleTop, singleTask and FLAG_ACTIVITY_CLEAR_TOP, and how do they affect the back stack?
What a strong answer covers: standard creates a new instance every time; singleTop reuses the instance at the top of the stack and calls onNewIntent; singleTask keeps one instance in its task and clears anything above it; singleInstance gives it its own task. FLAG_ACTIVITY_CLEAR_TOP removes activities above an existing instance. They're often used for notification or deep link entry points to avoid duplicate screens, and onNewIntent must update the UI.
How do you handle a deep link to a screen that needs login and data loading, so Back behaves sensibly and nothing is exploitable?
What a strong answer covers: Parse and validate all parameters (ids, not URLs to load); route through navigation (Navigation's deep link support builds a synthetic back stack so Back goes to the parent screen, not out of the app); if the user isn't signed in, go to login and resume the deep link afterwards; handle onNewIntent for warm starts; and never perform an action like a payment straight from a link without confirmation. Don't export activities that don't need to be.