What is a Android Component ?
What is a Android Component?
There are four components that can use within android
application. These components are coupled by
the application AndroidManifest.xml that describes each
component of the application and how they interact.
Activity
The activity is a building block of user interface. For example, an email
application might have one Registration activity, and another Login activity. If
an application has more than one activity, then one of them should be marked as
the activity that is presented when the application is launched.
Public
class MainActivity extends Activity {
}
Service
A service
is a component that runs in the background to perform long-running operations.
For example, a service might play music in the background while the user is in
a different application, or it might fetch data over the network without
blocking user interaction with an activity.
Public class MyBootLoader extends Service {
}
Broadcast Receivers
A broadcast
receiver (short receiver) is an Android component which
allows you to register for system or application events. All registered
receivers for an event are notified by the Android runtime once this event
happens.
For example, applications can register for the
ACTION_BOOT_COMPLETED
system
event which is fired once the Android system has completed the boot process.Public class MyAlert extends BroadcastReceiver {
Public void onReceive (context, intent){}
}
Content
Providers
The ContentProvider used to
get data from central repository. Android application contains content provider
to provide data to other applications. Content provider show data to
content resolver as one or many tables that will show same as relational
database.
Android provide Number of content providers that store common data such as contact information’s, item List information, and media files etc.
Android provide Number of content providers that store common data such as contact information’s, item List information, and media files etc.
Public class MyProvider extends ContentProvider {
Public void onCreate (){}
}
0 comments