The Android application consists of components that can be used to solve the basic function modules that are called. The Android system uses components to implement module calls within or between programs to address code reuse issues, which are a very important feature of Android. When programming, you declare shareable components in Androidmanifest.xml, and other applications can invoke these shared components directly after they are declared. For example, program A to achieve the function of file compression, and shared this component, program B no longer need to develop the file compression function, and directly invoke program A's shared components.
The Android system has 4 important components, activity, Service, Broadcastreceiver, and ContentProvider.
Activity is the rendering layer of the Android program, displaying a visual user interface and receiving interface events generated by user interaction, very similar to the concept of "form". An Android application can contain one or more activity, typically rendering an activity after the program starts, prompting the user program to start normally. Activity on the interface is typically a full-screen form, or it can be a non-full-screen Hover window or dialog box.
Service is typically used for apps that do not have a user interface, but that need to run in the background for a long time. For example, when playing MP3 music, using the service to play MP3 music, you can play MP3 music for a long time by turning off the player interface, and control the start, pause, and stop of MP3 music playback through the communication interface of the external public service.
Broadcastreceiver is a component used to accept and respond to broadcast messages. Most broadcast messages are system-generated, such as time zone changes, low battery level, or changing language options, but applications can also generate broadcast messages, such as data download complete. Broadcastreceiver does not contain any user interface, but can notify the user of important information by initiating activity or notification. Notification can prompt the user in a variety of ways, including flashing background lights, vibrating devices, making sounds or placing a persistent icon in the status bar.
ContentProvider is a standard shared data mechanism provided by the Android system that allows applications to access private data from other applications through ContentProvider. Private data can be files stored in the file system, or it can be a database in SQLite. There are also built-in ContentProvider within the Android system that provide important data information such as contact information and call history for the application.
The Android system, through its component mechanism, effectively reduces the coupling of the application, making it possible to share private data (ContentProvider) with other applications and to invoke private modules (Service) of other programs.
All Android components have their own lifecycle, called the component life cycle, which is the entire process from component building to component destruction.
Components of Android Development