Android operating system is the most popular open source platform for mobiles. These days many leading mobile companies integrate android into their handsets to offer flexible services to clients. As supported by one of the strongest object oriented language(JAVA), android shows flexibility and efficiency among various devices.
In this article we will understand the few important application components of android, which further uses by developers to build efficient applications. However, android has its own security sandbox to run android applications, which prevents collision of applications with each other. Android powered devices installs .apk(android package file) files to run desired applications.
Android provides four important components to build any android application. As every component has its own life-cycle so understanding of each component is must for any novice android developer.
An activity in android is like your computer welcome screen which presents single user display. In other words, Activity in android represents single screen with a user interface. We can understand Activity in terms of web applications For example: We creates numbers of web pages to build complete web application, similarly on the other hand android application consist of several Activities to run as a complete application.
a) An activity is a single screen of User Interface.
b) Each activity is completely isolated/different from each other.
c) Different application can call activity of another application, if permitted to do so.
d) An activity is implemented as a subclass of Activity.
Service is an important component in android which runs in the background to perform long running operations. For example: a service can display latest notification messages of your social accounts while playing games in your smartphone. A service component do not have an user interface compared to the activity component.
a) A service component perform long running operation.
b) A service component can perform remote processes.
c) A service component runs in background.
d) A service component doesn’t provide any user interface.
e) A service is implemented as a subclass of Services.
This component responds to system wide broadcast announcements. It also doesn’t provide any user interface. Broadcast Receivers is different from service component in many way as it works on events based broadcasts and do minimum work. For example: Broadcast receiver may displays battery low notification to your smartphone screen while accessing other applications or busy in any call. However, other applications can also initiate broadcasts.
a) We uses Broadcast Receivers for alerts/notifications purpose.
b) Broadcast Receiver doesn’t provide any user interface.
c) We can uses smartphones status bar for alerts/notifications.
d) A Broadcast Receiver is implemented as a subclass of BroadcastReceiver and each broadcast is delivered as an Intent object.
With content providers we can save data in SQLite database, on the web or any other persistent storage location, where application can easily access the data. This component is useful in reading and writing private data. For example: we can read and write important reminders or notes in database(within an application).
a) With Content Provider other applications can query and modify data, if permitted to do so.
b) We can store data in SQLite, Web or any other persistent storage format.
c) A Content Provider is implemented as a subclass of ContentProvider and must implement standard set of APIs that enable other apps to perform transactions.
Note: We can activate activities, services and broadcast receivers via asynchronous message called an “intent“. As Intent binds individual components to each other at run-time.
Uploaded by: Author