Android dev't 4
Android dev't 4
The android application components or core building blocks are the basic building blocks of an android
application and these components will allow system or user to access our app.
The followings are the basic core building blocks of android application components that can be used in
Android application:
Activities
Intent
Services
Broadcast Receivers
Content providers
Activities
Activity represents a single screen with a user interface (UI) and it is act as a entry point for users to
interact with app.
For example, a contacts app which has multiple activities like displaying a list of contacts, add new
contact and another activity shows to search for the contacts in the contacts list of an app. All activities
of a contacts app are independent to each other but these activities work together to provide a better
user experience.
Intents
An intent is a messaging object which is used to request an action from another component.
It is mainly used to perform following things:
Start an Activity
Start a Service
Deliver a Broadcast
Display a Webpage etc.
1. Implicit Intents
2. Explicit Intents
Services
Service is a component which is a background process to perform long running operations based on our
requirements. Service have not any user interface(UI) and it can run the apps in background for a long
time like play music in background when the user in different app.
We have two types of services available in android as follows:
Local Services
Remote Services
Local service is a service which is accessed from within the application whereas remote service is a
service which is accessed remotely from other applications running on the same device.
Broadcast Receivers
Broadcast Receivers is a component which allows a system to deliver events to the app like listening for
Incoming call, sms, sending a low battery message to the app etc. The apps can also initiate broadcasts
to let other apps know that required data available in a device to use it.It is used to handle
communication between Android operating system and applications.
Generally, we use Intents to deliver broadcast events to other applications and Broadcast Receivers use
status bar notifications to let user know that broadcast event occurs.
Content Providers
Content Providers are used to exchange the data between the applications 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 application can access.
By using Content Providers, other applications can query or modify the data of our application based on
the permissions provided by content providers. 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.