Android Fundamentals and Components

Android Fundamentals and Components

Before going to start development, we need to know about Android Fundamentals and Components, which we will use frequently while developing our android applications. From a developer’s perspective, some important building blocks / components of android are as bellow. Just have a look at them for now, we will discuss them in details latter on.

1. Activities

2. Services

3. Broadcast Receivers

4. Content Providers

When we are developing application, always we will have some requirements like, passing messages within an application (one screen to another) or between different applications.

For example: Let’s say a new message came to your phone, so we update the notification bar for that new message. So we will have to pass the information from message application to notification bar. Moral of the story is, the means of communication between the above mentioned components is through the bellow components.


2. Intent Filters

Let’s come to the GUI part. The User Interface elements are made up the below components, which we called:


2. Notifications

Now it is time to describe in details for each of the above components and its requirement and usages.

Android Activity

Activity is the basic building block of every visible android application. It provides the means to render a GUI. Every screen in an application is an activity by itself. We can call each visible component as an activity in android. Though more than one activities work together to present an application sequence, each activity is an independent entity. Just have a look at the below image, which explains the life cycle of an activity. I will explain the practical use of an activity, when we will develop our first “Hello World” application in this tutorial.

Life Cycle of an Activity in Android


To make you understand the real usage click here for complete example.

Android Services

Service is another building block of android applications which does not provide any UI. It is a program that can run in the background for an indefinite period. That means if we want to do a long operation (example: download data from internet), then we need to create an Android service for this purpose.

Android Services are little bit confusing. Before going to know What is Android Service? Lets have a clear picture in our mind that, What Android Service is not?

  • Please keep in mind that, Android Service is neither a separate process nor a thread. Then what exactly it is?
  • Using Android Service, we just inform the Android OS that, We are going to do a background processing.
  • Also Android Service exposes some functionality to other applications using the bind mechanism.

Generally Android Service are of 2 types.

  • Started Service (Unbounded)

This type of service is created and called by Android Activities. There is no 2 way communication between Android Activity and Service. The Activity just starts the service and does not care about the status of the service. The Service will finish it’s work and automatically stops when finish it’s job.

  • Bound Service (Bounded)

This type of Android Service is for 2 way communication. Suppose an Android Activity has started a bounded service, then Activity can be notified about the status by the service.

Don’t worry we will discuss in details about Android Services with an example in the example section.

LifeCycle of a Service in Android


To make you understand the real usage click here for complete example.

Android Broadcast Receivers

Broadcast Receiver is yet another type of component that can receive and respond to any broadcast announcements.

Let’s take an example; when a new message comes to your inbox, this information will be broadcasted for other applications. If any application wants to do something while a new message comes to your inbox, then it can receive the broadcasted message details (Like: sender’s number, content etc.) and process accordingly. Your application must be registered to that receiver to receive the broadcasted message.

Android Content Providers

Content Providers are a separate league of components that exposes a specific set of data to applications. Let’s take an example: If you want to search a contact in your contact database (Like: name, number etc), then you can use Content Provider for this purpose. You can say Content provider is the pointer in your application which points to a specific database from other application.


I think the basic knowledge of these four components is good enough to start development now, the knowledge of the means of communication between the components is also essential. So the android platform offers a new concept of communication through intents and intent filters.

To make you understand the real usage click here for complete example.

Android Intents

Intents are messages that are passed between components. So we have a question in our mind. Is it equivalent to parameters passed to API calls? Yes, it is close to that. However, the fundamental differences between API calls and intents is the way of invoking it. Lets have a look at the difference between these two in below points.

1. API calls are synchronous while intent-based invocation is asynchronous (mostly)

2. API calls are bound at compile time while intent-based calls are run-time bound (mostly)

It is these two differences that take Android platform to a different league.

In simple word, the core android components of an application — activities, services, and broadcast receivers — are activated through messages, called intents.

For example an activity can send an intent to the Android system which starts another activity. So an Intent is just a way to send a message in android.

Android intents are basically 2 types in nature.

1. Implicit Intents

Implicit intents specify the action which should be performed by other components or applications.

For Example: If you want to open an URL in a web browser from your application code, Then following code tells the Android system how to view a webpage. Typically the web browser is registered to this Intent but other component could also register themselfs to this intent. That means if you have installed web browsers like  IE, Mozilla Firfox and Google Chrome, then all browsers might be registered  to the intent (Intent.ACTION_VIEW) to show a web page as per you request.

If only one component (here web browser in our example) is found, Android starts this component directly. If several components are identifier by the Android system, the user will get an selection dialog and can decide which component should be used for that Intent.

2. Explicit Intents

Explicit intents explicitly defines the exact component which should be called by the Android system, by using the Java class are identifier.

The following code shows how to create an explicit intents and send it to the Android system. That means Android system will directly execute your intent request as you requested. Explicit intents are typically used within an application, as the classes in an application are controlled by the application developer. If you want to open an Android Activity from another activity, then below is the code for it using an intent to do so. Also you can send some data to that activity if required.

Android Intent Filters

To inform the system which implicit intents they can handle, activities, services, and broadcast receivers can have one or more intent filters. Each filter describes a capability of that component, a set of intents that the component is willing to receive.

Let’s take an Example: The ‘NotePadEditor’ activity of the sample Note Pad application has two filters — one for starting up with a specific note that the user can view or edit, and another for starting with a new, blank note that the user can fill in and save.

Basically IntentFilters are defined in the AndroidManifest.xml file. For BroadcastReceiver it is possible to define it in our code itself. An IntentFilters is defined by its category, action and data filters. It can also contain additional metadata. If a component does not define an Intent filter, then it can only be called by explicit Intents.

To make you understand the real usage click here for complete example.


Post By SmrutiRanjan (57 Posts)

Working @ Samsung as a Project Lead for Android Smartphones. I have been blogging since 2008. Previously I was writing articles for other bloggers, but finally I have started my own blog-"Techblogon".I am also an active contributor for the blog-"Gadgets n Gizmos World". Job is my necessity, but blogging is my passion.

Website: → Techblogon


15 Responses to Android Fundamentals and Components

  1. Gagandeep Singh says:

    awesome… !!!

  2. Dharmendra kumayu says:

    it’s really good!

  3. Abinash says:

    I am new to android development… though i have 4.5 years experience in .net technologies…..i find this man named SmrutiRanjan is really a great guy…its really very easy to understand..thank bro….
    Abinash Routray

  4. Manish Agarwal says:

    Hey there.
    I am totally new to app development and don’t know a thing about API.
    Should I first learn something about API to continue with your tutorials?
    If yes, may you kindly provide to some good articles or tutorials about the same?

    • SmrutiRanjan says:

      Dear Manish,
      API are just the collection of Android functions, Which has already exist with the default Android SDK. We just need to call them in our application, so don’t worry.

  5. P.S.Sanatan says:

    i came across your blog and i think you can help me.I don’t know about java programming and i have basic idea about the c and c++.Then what should be the procedure for me to learn the anroid application development.Please guide me…
    Thank you

    • SmrutiRanjan says:

      Dear Sanatan,
      It is not necessary to know java for android.
      Just setup all android tool, then just learn some common fundamentals like activity, intent, broadcast receiver etc. then start will hello world program
      You can refer to my site, it is written in such a way that begginers can read from the top to the bottom, which will help you to go ahead step by step.

      • P.S.Sanatan says:

        Thank you for your valuable guidance,i am going to do the same thing as told by you and hope you will guide in my way of learning anroid.
        Thank you.

  6. Jones sabo newest charms says:

    Fantastic goods from you, man. I have understand your stuff previous to and you’re just too great.

  7. Jones sabo says:

    Some genuinely excellent blog posts on this website , appreciate it for contribution.

  8. leela says:

    hai sir good morning iam new to Android technology iam learning basics from ur website its really good and i want to learn android technology is it good has it future for this technology i want to know please give guidance for this and also jobs rating and openings for this technology

  9. Anil SIngh says:

    You are great. I just want to confirm is an activity killed when we press back button on our device?

  10. principally says:

    Awesome things here. I am very glad to peer your article. Thank you a lot and i’m having a look forward to contact you. Will you please drop me a mail?

  11. Faisal Goraya says:

    i cannot understand, What is android intents? please explain android intent using simple example?

Leave a Reply

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

× eight = 32

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">