Android Application Components

Application components are the essential building blocks of an Android application. These components are loosely coupled by the application manifest file AndroidManifest.xml that describes each component of the application and how they interact.

Android Components
Android Components

There are following four main components that can be used within an Android application:

ComponentsDescription
ActivitiesThey dictate the UI and handle the user interaction to the smartphone screen
ServicesThey handle background processing associated with an application.
Broadcast ReceiversThey handle communication between Android OS and applications.
Content ProvidersThey handle data and database management issues.
Android Application Components

1. Activities

An activity is the entry point for interacting with the user. It represents a single screen with a user interface.

For example, an email app might have one activity that shows a list of new emails, another activity to compose an email, and another activity for reading emails. 

public class MainActivity extends Activity 
{ 
      //code 
}

An activity facilitates the following key interactions between system and app:

  • Keeping track of what the user currently cares about  (what is on screen)
  • Knowing that previously used processes contain things the user may return to (stopped activities)
  • Helping the app handle having its process killed
  • Providing a way for apps to implement user flows between each other

2. Services

service is a general-purpose entry point for keeping an app running in the background for all kinds of reasons.

It is a component that runs in the background to perform long-running operations or to perform work for remote processes. 

A service does not provide a user interface.

public class MyService extends Services 
{ 
//code 
}

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.

3. Broadcast Receivers

broadcast receiver is a component that enables the system to deliver events to the app outside of a regular user flow, allowing the app to respond to system-wide broadcast announcements.

public class Broadcast_Name extends BroadcastReceiver 
{
//code
}

Because broadcast receivers are another well-defined entry into the app, the system can deliver broadcasts even to apps that aren’t currently running. 

Although broadcast receivers don’t display a user interface, they may create a status bar notification to alert the user when a broadcast event occurs.

4. Content Providers

content provider manages a shared set of app data that you can store in the file system, in a SQLite database, on the web, or on any other persistent storage location that your app can access. 

public class Provider_Name extends ContentProvider 
{
//code
}

Content providers are also useful for reading and writing data that is private to your app and not shared.

Additional Components of Android Application

There are additional components which will be used in the construction of above mentioned entities, their logic, and wiring between them. These components are:

Components Description
Fragments Represents a behavior or a portion of user interface in an Activity.
ViewsUI elements that are drawn onscreen including buttons, lists forms etc.
LayoutsView hierarchies that control screen format and appearance of the views.
IntentsMessages wiring components together.
ResourcesExternal elements, such as strings, constants and drawables pictures.
ManifestConfiguration file for the application.

Activating components

Three of the four component types—activities, services, and broadcast receivers—are activated by an asynchronous message called an intent.

Intents bind individual components to each other at runtime. You can think of them as the messengers that request an action from other components, whether the component belongs to your app or another.

Related posts

One Thought to “Android Application Components”

  1. […] Intent and Intent Filters are used as a message-passing mechanism that works both within your application, and between applications or between different app components. […]