Android Application Components
Android Application Components
Android Application Components
6
Android Application Components
(Activities, Intents, Views, Layouts, Services)
In android, application components are the basic building blocks of an application and these
components will act as an entry point to allow system or user to access our app.
Following are the basic core application components that can be used in Android application.
Activities
Intents
Content Providers
Broadcast Receivers
Services
All these application components are defined in android app description file
(AndroidMainfest.xml) like as shown below.
Android Activities
In android, Activity represents a single screen with a user interface (UI) and it will acts an entry
point for user’s to interact with app.
For example, a contacts app which is having a multiple activities like showing a list of contacts,
add new contact, and another activity to search for the contacts. All these activities in contact app
are independent of each other but will work together to provide a better user experience.
Android Intents
In android, Intent is a messaging object which is used to request an action from another
component.
Starting an Activity
Starting a Service
Delivering a Broadcast
1
There are two types of intents available in android, those are
1. Implicit Intents
2. Explicit Intents
Android Services
In android, Service is a component which keep an app running in the background to perform
long running operations based on our requirements. For Service, we don’t have any user interface
and it will run the apps in background like play music in background when the user in different
app.
Local Services
Remote Services
In android, Broadcast Receiver is a component which will allow a system to deliver events to the
app like sending a low battery message to the app. The apps can also initiate broadcasts to let
other apps know that required data available in a device to use it.
Generally, we use Intents to deliver broadcast events to other apps and Broadcast Receivers use
status bar notifications to let user know that broadcast event occurs.
In android, Content Providers are used to exchange the data between the apps based on the
requests. The Content Providers can share the app data that store in the file system, SQLite
database, on the web or any other storage location that our app can access.
By using Content Providers, other apps can query or modify the data of our app based on the
permissions provided by content provider. For example, android provides a Content Provider
(ContactsContract.Data) to manage contacts information, by using proper permissions any app
can query the content provider to perform read and write operations on contacts information.
Additional Components
In android, we have an additional components which are used to build the relation between
above components (Activities, Intents, Content Providers, Services and Broadcast Receivers) to
implement our application logic, those are
2
Componen
t Description
Fragments These are used to represent the portion of user interface in an activity
Layouts These are used to define the user interface (UI) for an activity or app
Views These are used to build user interface for an app using UI elements
like , TextView, Buttons, lists, etc.
Resources To build android app we required external elements like images, audio
files, etc. other than coding
These are the main application components which are required to build any android application
based on our requirements.
Questions