Android Application Components
There are following four main components that can be used within an Android application:
Activity:
Activity represents User Interface. For example, an Music player app might have one activity that shows list of songs, another activity to play an song and another for creating play list and so on. If an application has one or more activity then one of the activity should be displayed when the application is launched. An activity is implemented as subclass of Activity.
Eg.
Public class test extends Activity
{
}
Service:
Service is a component that is used for performing background task or to perform work for remote processes. A service does not provide UI. 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. An service is implemented as subclass of service
Eg.
Public class test extends Service
{
}
Content Provider:
A content provider component supplies data from one application to others on request. Such requests are handled by the methods of the ContentResolver class. You can store the data in the file system, an SQLite database, on the web, or any other persistent storage location your app can access. Through the content provider, other apps can query or even modify the data. For example phonebook has list of contacts which can be shared by whatsApp.
Broadcast Receiver:
Broadcast Receivers simply respond to broadcast messages from other applications or from the system. A broadcast receiver (receiver) can be registered to listen to system messages and intents. A receiver gets notified by the Android system if the specified event occurs. For example, when we like any page on facebook then its messages are coming. An Broadcast Receiver is implemented as subclass of BroadcastReceiver
Eg.
public class MyReceiver extends BroadcastReceiver
{
public void onReceive(context,intent)
{
}
}
No comments:
Post a Comment