blog posts

Android – Application components and introduction of additional components

Program components are the basic building blocks of an Android application. These components are linked together by the AndroidManifest.xml application manifest file, which describes each component of the application and how they interact.

There are four main components that can be used in an Android application –

Number Component and description
1 Activities- Set the UI and control the user interaction with the smartphone screen.
۲ Services – Control the background processing associated with an application.
3 Broadcast Receivers – Control the connection between the Android operating system and applications.
4 Content Providers – Deal with database and data management issues.


Activity represents a single screen with a user interface, in short Activity performs on-screen functions. For example, an email application might have Activity that displays a list of new emails, another Activity to write email, and another Activity to read email. If the program has more than one activity, one of them should be specified as the activity that is presented when launching the program.

Activity is run as a subclass of the Activity class as follows –

public class MainActivity extends Activity {



A service is a component that runs in the background for long-term operations. For example, one service may play music in the background while the user is using another application. Or it may download data over the network without interfering with user activity.

Services run as a subclass of the Service class as follows –

public class MyService extends Service {


Broadcast Receivers

Broadcast Receivers simply respond to messages broadcast from other applications or from the system. For example, applications can start broadcasting so that other applications know that some data has been downloaded to the device and is available for use, so it is the Broadcast Receiver that intercepts this connection and takes appropriate action. .

The Broadcast Receiver is implemented as a subclass of the BroadcastReceiver class, and each message is played as an Intent object.

public class MyReceiver extends BroadcastReceiver {

public void onReceive (context, intent) {


Content Provider

The Content Provider component distributes data from one application to another upon request. These requests are handled with ContentResolver class methods. The data may be stored entirely in a file system, database, or other location.

The Content Provider is implemented as a subclass of the ContentProvider class and must run a standard set of APIs to enable other applications to trade.

public class MyContentProvider extends ContentProvider {

public void onCreate () {{


Additional components or components

There are other components that are used in the construction of entities, logic and the relationship between them. These components are:

Number Components and descriptions
1 FragmentsShows part of the user interface in an Activity.
۲ ViewsUI elements that include buttons, lists, etc. on the screen.
3 LayoutsView a hierarchy that controls the screen format and appearance of views.
4 IntentsJob request messages from the system.
5 ResourcesExternal elements, such as strings, constants, and printable images.
6 ManifestApplication configuration file.