Android Component Security
Communication between components
Android uses intents to pass actions, data, and extra parameters between components. Whether an external app can call a component and whether the caller is authorized to perform a particular operation are separate checks.
Four component types
| Component | Role | Review focus |
|---|---|---|
| Activity | Hosts user interfaces and interactions. | Verify identity and permissions at the point of use for personal data or account changes. |
| Service | Provides background work and may accept bindings. | Distinguish internal services from external interfaces and limit callable operations. |
| BroadcastReceiver | Receives system or application broadcasts. | Limit receipt and sender permissions for the use case. Handle empty or incomplete messages. |
| ContentProvider | Manages access to data through URIs. | Check read, write, and temporary grants separately for the specific resource. |
Explicit and implicit intents
An explicit intent specifies the target component. An implicit intent lets Android match a recipient based on the action, category, and data. When the recipient is known, narrowing the target helps keep identifiers and private parameters within their intended scope.
Dynamic receiver lifecycle
Unregister a receiver at the corresponding lifecycle boundary. A receiver that outlives its screen can retain a reference to a closed UI or continue to receive events after they are needed.