Intents & Deep Linking Flashcards
ANDROID › Components
- What is the difference between an explicit and an implicit intent?
- An explicit intent names the exact target component (class/ComponentName) and bypasses intent filters, so it is always delivered. An implicit intent declares only an action/data/category and lets the system find a matching component via intent filters.
- Which category must an activity's intent filter declare to receive implicit intents from startActivity()?
- CATEGORY_DEFAULT (android.intent.category.DEFAULT). The system automatically adds CATEGORY_DEFAULT to implicit intents launched via startActivity()/startActivityForResult(), so a filter without it will not match.
- What are the three tests the system uses to match an implicit intent to an intent filter?
- The action test (intent's action must match one filter action), the category test (every category in the intent must appear in the filter), and the data test (URI scheme/host/path and MIME type must match the filter's data elements).
- What is a PendingIntent and why is it used?
- A PendingIntent is a token wrapping an Intent that you hand to another app or system service (notifications, AlarmManager), letting it execute the intent later with your app's identity and permissions, as if your process fired it.
- On Android 12+, what mutability flag must every PendingIntent specify, and which is preferred?
- You must pass FLAG_IMMUTABLE or FLAG_MUTABLE. FLAG_IMMUTABLE is preferred for security; use FLAG_MUTABLE only when the receiver must fill in fields, e.g. direct-reply notifications or AlarmManager EXTRA_ALARM_COUNT.
- What distinguishes an Android App Link from a regular custom-scheme deep link?
- An App Link is an http/https deep link verified via Digital Asset Links (autoVerify + assetlinks.json proving domain ownership). Verified App Links open directly in the app with no disambiguation dialog; custom-scheme or unverified web links may show a chooser or open the browser.
- Which categories and action must an intent filter include to be reachable as a deep link from a web browser?
- action android.intent.action.VIEW, plus category DEFAULT and category BROWSABLE. BROWSABLE makes it launchable from a browser, DEFAULT lets it respond to implicit intents, and VIEW is the standard view action.
- Where must the Digital Asset Links file live for App Links verification, and what does it contain?
- It must be served as JSON at https://domain/.well-known/assetlinks.json. It lists the relation handle_all_urls, the app's package_name, and the app signing certificate's sha256_cert_fingerprints.
- What replaced startActivityForResult(), and why is it preferred?
- The Activity Result API: registerForActivityResult() with a contract such as ActivityResultContracts.StartActivityForResult(), then launch(intent). It is type-safe, lifecycle-aware, and decouples result handling from request codes and onActivityResult().