Four Basic Component of Android

In this tutorial, we will learn basic component of android that is, used, for android development. There are four types of component such as Activity, Services, Broadcast Receiver, Content Provider.

Android is open source and Linux-based operating system for mobile devices like, smartphones and tablets.

Android applications are developed in Kotlin, Java language.Kotlin is better to build android applications and very easy to learn when compared to java.

What are the Basic Component of Android?

The basic component of android are-

  • Activity
  • Services
  • Broadcast Receiver
  • Content Provider

Activity:

A single screen in the application with UI components is called as Activity.

In android, for every Activity we have to create two files.These are:-

1- XML file (for layout)

2- and Kotlin file (for creating Activity).

For Example –

When you are opening a flipkart app from playstore,the ordering screen ,payment screen shows an activity.

We can write an activity as:-

Public class MainActivity extends Activity
}

Service :

A long running background process without any user interaction is called a services.

For Example –Alarm Services, Media player, FM player etc.

We can write a service as:-

Public class MyService extends Service{}

Broadcast Receivers:

Broadcast receivers are registered for system events.

For Example –headset plugin, charger connecter/disconnected, screen on/off, making/receiving call, sending/receiving SMS etc.

We can write a Broadcast receivers as:-

Public class MyReceiver extends BroadcastReceiver {}

Content Providers:-

It is used to share the data between multiple applications.

In android, there is one feature i.e.,security. So, we can’t access the other applications data into our applications directly but with the help of content provider, we can access the data into our applications.

For Example –Contacts , Call log, Calendar ,Settings, Media, Messages etc.

We can write a content provider as:-

Public class MyContentProvider extends ContentProvider {}

Read more

Application developer|Technical blogger|Youtuber(MASTERMIND CODER)|owner at www.yourtechnicalteacher.com