Android Application Components

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.

The manifest file contains the app’s metadata, its hardware configuration, and platform requirements, external libraries, and required permissions.

The 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 the android app description file (AndroidMainfest.xml) like as shown below.



<?xml version="1.0" encoding="utf-8"?>
<manifest …..>
    <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" ……>
        <activity android:name=".MainActivity" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

       …….

    </application>
</manifest>

This is how we can define an android application components in AndroidManiFest.xml file.

Android Activities

In android, Activity represents a single screen with a user interface (UI) and it will acts an entry point for the user’s to interact with app. 

For example, a contacts app that is having multiple activities like showing a list of contacts, add a new contact, and another activity to search for the contacts. All these activities in the contact app are independent of each other but will work together to provide a better user experience.

To know more about Activities in android check Android Activities.

//JAVA
public class MainActivity extends Activity {
}
//Kotlin
class MainActivity : AppCompatActivity() {
}

Android Intents

In android, Intent is a messaging object which is used to request an action from another component.

In android, intents are mainly used to perform the following things.

  • Starting an Activity
  • Starting a Service
  • Delivering a Broadcast

There are two types of intents available in android, those are

  1. Implicit Intents
  2. Explicit Intents

To know more about Intents in android check this Android Intents.

Android Services

In android, Service is a component that keeps 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.

We have two types of services available in android, those are

  • Local Services
  • Remote Services

To know more about Services in android check this Android Services.

//JAVA
public class ServiceName extends Service {
}
//Kotlin
class ServiceName : Service() {
}

Android Broadcast Receivers

In android, Broadcast Receiver is a component that 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 the user know that broadcast event occurs.

To know more about Broadcast Receivers in android check this Android Broadcast Receivers.

//JAVA
public class MyReceiver  extends  BroadcastReceiver {
   public void onReceive(context,intent){}
}

Android Content Providers

In android, Content Providers are useful to exchange the data between the apps based on the requests. The Content Providers can share the app data that stores 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.

To know more about Content Providers in android check this Android Content Provider.

//JAVA
public class contentProviderName extends  ContentProvider {
   public void onCreate(){}
}
//Kotlin
class contentProviderName : ContentProvider() {
  override fun onCreate(): Boolean {}
}

Additional Components

In android, we have additional components which are used to build the relationship between the above components (Activities, Intents, Content Providers, Services and Broadcast Receivers) to implement our application logic, those are

ComponentDescription
FragmentsThese are used to represent the portion of user interface in an activity
LayoutsThese are used to define the user interface (UI) for an activity or app
ViewsThese are used to build a user interface for an app using UI elements like buttons, lists, etc.
ResourcesTo build an android app we required external elements like images, audio files, etc. other than coding
Manifest FileIt’s a configuration file (AndroidManifest.xml) for the application and it will contain the information about Activities, Intents, Content Providers, Services, Broadcast Receivers, permissions, etc.

These are the main application components which are required to build an android application based on our requirements.

That’s it!
You have successfully completed the post. Do Share : )

Peace Out!

Also Read – Android Architecture


Check Out Deals on -> Amazon , Flipkart , Myntra , Adidas , Apple TV , Boat , Canva , Beardo , Coursera , Cleartrip , Fiverr , MamaEarth , Swiggy, KFC


One comment

Leave a Reply

Your email address will not be published.