The main types of Android application components are: Active (activity) service broadcast recipient (broadcast receiver) content provider (contents Provider) Intent (intent) Widgets (widget) notifications (notification)
1. Activities:
The presentation layer of the application, my user shows the interface. An activity typically presents a visual user interface. An application can contain one or more activity. Typically, each application starts with an activity that displays the first interface, initiates a new activity in the activity currently being presented to the user, or invokes the activity of another application, enabling a jump from one interface to another.
2. Service:
The service runs in the background and does not show the user interface. They can provide data source updates for the activity in the foreground and trigger notifications. For example, users can start a service to play background music when they are dealing with something else, or start a service on the mail client to download new messages from a intermittent connection mail server.
Another important application of the service is to enable interprocess communication through Aidl (Android Interface definition Language Android Interface Definition language). For example, in an application, other application components can interact directly with the service that is running in the background of the application, and on the other hand, multiple applications through the service can implement communication between them in the context of ensuring that the process is secure.
3. Content providers
A content provider is a mechanism for inter-application data sharing that provides a way for multiple applications to share storage data, which is equivalent to a cross-application data operation that allows other applications to increase their SQL data, images, sounds, or other data types through ContentProvider. , delete, change, check and other operations. ContentProvider provides a unified interface for data manipulation, providing four interface functions for applications: INSERT, UPDATE, and query,content provider mask the specifics of the implementation of data operations, The application only needs to invoke the corresponding interface function via ContentProvider, which greatly simplifies the operation of data across applications.
4. Broadcast Recipients
The broadcast recipient does not perform any tasks. Each broadcast receiver receives broadcast notifications from the system or application and responds to broadcast notifications. Many things can lead to decent broadcasts, such as changes in the time zone of a mobile phone, low battery level, user changes to system language settings, and so on. Applications can also send broadcast notifications, such as notifying other applications that some data has been downloaded.
5. Intentions
The purpose of intent is to pass information and coordinate work between components. Android's standalone application components need to be called, coordinated, and eventually integrated into a real Android app. The coordination between components is mainly done by intent, which acts as a link between activity, Content provider and service. A intent contains a single operation information, such as the desired action, the data associated with the action, and the information required by the Android system. Based on the information provided by this intent, Android is responsible for locating the component that satisfies this information, passing the intent to the component, and completing the call to the component. So intent here plays a role as a media intermediary, specifically to provide components to call each other to exchange information, to achieve the caller and the call between the link.
Android Application Components