What are Intents and how are they used in Android applications?
Instruction: Describe the concept of Intents, including the difference between explicit and implicit intents, and provide examples of their usage.
Updated
Official answer
An Intent describes a requested component action, including an optional explicit component, action, data URI, MIME type and extras. Common uses include Activity launches, supported service starts/binds and broadcasts. ContentProvider reads normally use ContentResolver, although an Intent can carry the content URI to share.
An explicit Intent names the exact component. It is commonly used for an internal detail Activity, but can target an exported accessible component in another app too; permissions and export rules still apply. For an internal detail screen, select the declared DetailActivity and pass a small record ID rather than a large object graph.
An implicit Intent leaves the component unspecified and supplies an action/data/type for resolution. For example, ACTION_VIEW with an encoded geo URI can request a map view. Handle ActivityNotFoundException with a useful fallback; a preflight resolution check is not a guarantee the handler will remain available. Use a chooser when the user should select a sharing destination.
Do not send secrets to an unconstrained implicit recipient. Share files through a permitted content URI and limited temporary grants rather than exposing a filesystem path. A receiving component validates action, URI and extras and enforces authorization even when the Intent is explicit. Use explicit intents for services; modern Android restricts implicit service binding/start behavior.
Successful launch only means the request was handed off, not that the user completed the external task. Where a result is needed, use an appropriate Activity Result contract and handle cancellation, missing/invalid output and loss of the original screen.
Intent routing and restrictions, Secure file sharing, Activity results