Android The four components: Activity , Service , Broadcastreceiver , Content Provider .
Content Provider belongs to one of the components of an Android application, and as the only way to share data between applications, the content Provider main function is to store and retrieve data and provide access to other applications with the interface to the data
①activity is a component of the Android app that is responsible for interacting with the user--roughly imagining it as a JFrame control in swing programming. However, it differs from the jframe in that the JFrame itself can set up the layout Manager and constantly add components to jframe, but the activity can only display the specified component through setcontentview (View) .
Activity provides a visual user interface for Android apps, and if the Android app requires multiple user interfaces, the Android app will contain multiple activity, multiple activity components Activity Stack . The activity currently active is at the top of the stack.
The view component is the base class for all the U-I controls, container controls , and the view component is what the user actually sees in the Android app. But the view component needs to be placed in a container component, or it can be displayed using activity. If you need to display the specified view through an activity, call the activity's Setcontentview () method.
②service is tied to the status of activity and represents a separate Android component. The difference between service and activity is that theservice is typically run in the background , and it generally does not need to interact with the user , so the service component does not have a graphical user interface. Service components need to inherit service base classes. Once a service component is run, it has its own life cycle, andservice components are typically used to provide back-office services to other components or to monitor the running state of other components .
③broadcastreceiver is another important component in Android applications, and Broadcastreceiver represents a broadcast message receiver . From a code implementation perspective, Broadcastreceiver is very similar to listeners in event programming. Unlike the normal event listener, the event source that the normal event listener listens to is the object in the program, while the Broadcastreceiver listens to other components in the Android app for the event source . Using the Broadcastreceiver component to receive broadcast messages is relatively straightforward, as long as developers implement their own broadcastreceiver subclasses and rewrite the onreceive (Context context,intent Intent) method. When another component sends a broadcast through the Sendbroadcast (), SENDSTICKYBROADCST (), or Sendorderedbroadcast () method, the Broadcastreceiver is also "interested" in the message (via Intentfilter configuration), the Broadcastreceiver onreceive (Context context,intent Intent) method will be triggered. After developers implement their own broadcastreceiver, there are usually two ways to register this system-level "event listener".
--in Java code, register broadcastreceiver with the Context.registreceiver () method.
--Use the <receiver......> element in the Androidmanifest.xml file to complete the registration.
④contentprovider for Android applications, components must be independent of each other, and if these Android apps need real-time data exchange between them. For example, in the development of a text messaging program, when sending text messages need to read from the contact management application of the specified contact data----This requires a real-time exchange of data between multiple applications.
The Android system provides a standard for this cross-application data exchange , ContentProvider. When users implement their own contentprovider, they need to implement the following abstract methods.
Insert (Uri, contentvalues): Inserts data into ContentProvider.
Deleter (uri,contentvalues): Deletes the specified data in the Contentprovdier.
Update (Uri, Contentvalues, String, string[]): Updates the specified data in the ContentProvider.
Query (Uri, string[], String, string[], string): Queries data from ContentProvider.
Commonly used in conjunction with ContentProvider is Contentresolver, where one application exposes its own data using ContentProvider, while another application accesses the data through Contentresoler.
Intent and Intentfilter strictly say that intent is not a component of Android, but it is very useful for Android apps----It is a vehicle for communication between different components within an Android application. When the Android runtime needs to connect to different components, it usually needs to be implemented with intent. intent can launch another activity,service,broadcastreceiver in the app.
Excerpt from: http://www.cnblogs.com/SharkBin/archive/2013/07/06/3175297.html
Four components of Android