Android App components
App components are the essential building blocks of an Android app. Each component is an entry point through which the system or a user can enter your app.
There are four different types of app components:
- Activities
- Broadcast receivers
- Content providers
- Services
- Activities
An activity is the entry point for interacting with the user. It represents a single screen with a user interface.
2. Broadcast receivers
A broadcast receiver is a component that enables the system to deliver events to the app outside of a regular user flow, allowing the app to respond to system-wide broadcast announcements. Because broadcast receivers are another well-defined entry into the app, the system can deliver broadcasts even to apps that aren’t currently running.
A broadcast receiver is implemented as a subclass of BroadcastReceiver and each broadcast is delivered as an Intent object. For more information, see the BroadcastReceiver class.
3. Content providers
A content provider manages a shared set of app data that you can store in the file system, in a SQLite database, on the web, or on any other persistent storage location that your app can access. Through the content provider, other apps can query or modify the data if the content provider allows it.
4. Services
A service is a general-purpose entry point for keeping an app running in the background for all kinds of reasons.
It is a component that runs in the background to perform long-running operations or to perform work for remote processes. A service does not provide a user interface.
There are two types of services that tell the system how to manage an app: started services and bound services.
— Started services tell the system to keep them running until their work is completed. This could be to sync some data in the background or play music even after the user leaves the app.
— Bound services run because some other app (or the system) has said that it wants to make use of the service. This is basically the service providing an API to another process. The system thus knows there is a dependency between these processes, so if process A is bound to a service in process B, it knows that it needs to keep process B (and its service) running for A. Further, if process A is something the user cares about, then it also knows to treat process B as something the user also cares about.