Tuesday, 2 June 2015

Android Application Component

App components are the essential building blocks of an Android app. each component plays a specific role—each one is a unique building block that helps define your app's overall behavior. whenever you want to use a component you must include it in Project manifest file, AndroidManifest.xml.
There are four different types of app components. Each type serves a distinct purpose and has a distinct life-cycle that defines how the component is created and destroyed.
 1). Activity
 2) Services
 3) Content providers
 4) Broadcast receivers
 
 1). Activity
      An activity represents a single screen with a user interface. For example, an email app might have one activity that shows a list of new emails, another activity to compose an email, and another activity for reading emails.An activity is implemented as a subclass of Activity.

 2) Service
      Service runs in the background to perform long-running operations or to perform work for remote processes. A service does not provide a user interface. For example, a service might play music in the background while the user is in a different app, or it might fetch data over the network without blocking user interaction with an activity. A service is implemented as a subclass of Service.

3) Content providers
     A content provider manages a shared set of app data. The data can be stored in the file system, an SQLite database, on the web, etc. Other apps can query or even modify the data (if the content provider allows it). e.g, A content provider is provided by android system that manages the user's contact information. As such, any app with the proper permissions can query part of the content provider (such as ContactsContract.Data) to read and write information about a particular person. A content provider is implemented as a subclass of ContentProvider class.

4) Broadcast receivers
    A broadcast receiver is a component that respond to broadcast messages from other applications or from the system. Many broadcasts originate from the system. e.g, a broadcast announcing that the screen has turned off, the battery is low etc.
A broadcast receiver is implemented as a subclass of BroadcastReceiver class and each message is broadcasted as an Intent object.




No comments:

Post a Comment