How do Android components collaborate in a podcast application?
Instruction: Use a podcast app that displays episodes, plays audio while the screen is absent and shares an episode file. Explain the four Android component types, how they communicate, and their lifecycle and access boundaries.
Updated
Official answer
The four platform component types are Activity, Service, BroadcastReceiver and ContentProvider. They are operating-system entry points, not a requirement to create four separate classes for every feature.
For this example, an Activity hosts the podcast list and player controls; it can contain several destinations. A suitably configured media playback service owns ongoing playback when the screen is absent, following foreground-service and media requirements. The screen observes player state rather than owning playback solely through an Activity reference.
A short BroadcastReceiver may react to an eligible system event and schedule the appropriate follow-up. It is not a permanent listener process or a place for an unlimited download. A ContentProvider, such as a configured FileProvider, can expose an episode file to an authorized client through a content URI and a temporary read grant. The recipient uses ContentResolver, not an intent to query the provider itself.
Intents route activity launches, service starts/binds and broadcasts. They can also carry a provider URI when sharing. Validate incoming values and caller access; matching an intent filter is not authorization. Services use their process's main thread by default, so blocking operations still need an appropriate worker context.
Test leaving the screen, denied sharing access and process recreation. Durable episode metadata belongs in storage; component instances are not durable state.