An Introduction to Android – Part I: Application Components

by Aamir Bhatt

Android application components are the building blocks of Android apps. These are the entry points for the system to enter the app. Each one has its own unique role to play and in turn defines behavior of app. 

The following are the main components of Android:

  1. Activity
  2. Services
  3. Broadcast Receiver
  4. Content Provider

Apps are made from components. Android initiates and runs them as needed. Each component has its own purpose and API.

Activity: This is the main component which user sees,when they run the Application. Activity are responsible for GUI (Graphical User Interface) to user. The rest of the components work behind the scenes i.e in background without any user interface. Activity should do single, focused tasks, e.g., Phone dialer is Activity.

Service: This component is responsible for running long background operations or processes. There is no GUI for service, e.g., Running music is a Service.

Broadcast Receiver: This is responsible for events – that listen for or respond to the events. Events are represented by intent class. These intents are then routed to broadcast receiver. E.g SMS message is a broadcast receiver. For sending the message there is one broadcast receiver and for receiving message there is another broadcast receiver.

Content Provider: This  component allows multiple applications to store and share data. This is similar to our database style interface although it is responsible for interprocess communications between the Apps. E.g., Email app uses content providers for viewing inbox mails.

Source Code

Activity

To build Activity inherit AppCompatActivity to your java class,

import android.support.v7.app.AppCompatActivity;
class MyActivity extends AppCompatActivity{

}

Service

Here we subclass Service
import android.app.Service;
public class MyService extends Service{
}

Broadcast Receiver

import android.content.BroadcastReceiver;
class MyReceiver extends BroadcastReceiver{
}

Content Provider

import android.content.ContentProvider;
class="prettyprint notranslate prettyprinted">public class MyApplication extends  ContentProvider {

}

Building An Application

ZnJvbT1jc2RuJnVybD1jbWJ3NUNabGxtWnB4R2N0bDJjdFFHYnBWbll2TVhabkZXYnA5U2J2Tm1Ma2wyYnlSbWJoNWljbEIzYnNWbWRsUjJMdm9EYzBSSGE

This flow diagram shows the process that depicts your application.

Android Project: This contains our source code as well as non source code that make up the application.

Compilation And Packaging: Compiles our source code and prepares the resources.

Apk: Output of compilation and packaging process is Apk (Android package). An APK file contains all of the codes of program (such as .dex files), resources, assets, certificates, and manifest file.

Signing: APK is digitally signed to identify developer.

Device or Emulator: Finally your application is installed in your device or emulator.

Stay tuned as I will continue to cover Android Fundamentals in my coming blogs!

To learn more about

Contact Us

Leave a Reply

Your email address will not be published. Required fields are marked *

Mobile Research Apps

We have deep expertise in design and development of mobile research apps that work on both iOS and Android securely.

Contact us now

Popular Posts