How do you use Intents for communication between components in an Android application?
Instruction: Provide examples of explicit and implicit Intents and discuss how they are used for inter-component communication.
Updated
Official answer
For an internal details screen, I would use an explicit Intent naming the declared activity and attach a small stable item ID. The receiving activity checks that the extra is present and valid, then loads the item through its repository and enforces access rules. A class name in an Intent does not itself grant access.
For an external web link, an implicit ACTION_VIEW Intent carries the intended HTTPS URI. Launch only in the appropriate user interaction, handle ActivityNotFoundException, and show a clear unavailable-action state. Do not assume every device has a handler. If the URI came from untrusted input, validate the allowed scheme/host against the feature's policy before handing it off.
For sharing a generated report, a chooser can let the user select a destination. Share a content URI through a configured FileProvider with the minimum temporary read grant, rather than exposing a raw filesystem path or a broad directory. Sending an intent does not prove the recipient completed the requested action.
Use the Activity Result APIs when the workflow requires a result and handle cancellation. Services and broadcasts have separate lifecycle/execution and export rules; an implicit intent should not select an arbitrary service for privileged work.
Test missing/invalid IDs, denied access, no handler, user cancellation and a recipient that returns malformed data. Measure successful task completion and failures; activity dwell time alone does not demonstrate correct communication.