Android App Development: Intents and Intent filters

Intents are used by an application to interact with the phone’s hardware components or other applications, or to start a service or activity with a certain piece of data or to broadcast that an event has occurred.

Using Intents to launch phone activities:

We can use Intents to launch the phone’s basic activities such as the phone dialer, the browser or search.

These intents are called Implicit Intents cause you don’t specify the activity you want to launch, rather Android determines the proper activity to launch based on the required action. Also when the launched activity finisheds its work, the original activity has no information that the launched activity has finished it’s work

In this example we create an intent that performs a phone number dial action. We don not specify that we want the dialer activity to launch, rather we specify that we want to dial a number and Android launches the dialer activity to perform this action

Consider this activity: consists of a TextView and a button to dial the number in the text view.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android=""
    android:text="Enter the phone number"

When you press the button the phone dialer launches and then you can call the number.

This is done using the following code:

btnDial.setOnClickListener(new OnClickListener() {

   public void onClick(View v) {
    // TODO Auto-generated method stub

Intent dialIntent=new Intent(Intent.ACTION_DIAL,Uri.parse("tel:"+(txtNumber.getText()).toString()));


Notice that the dialer has been launched but the user has to press the call button to make a call.

If you want the phone to dial the number automatically you could have used this intent:


If you use this it requires adding the following permission to the manifest file:

<uses-permission android:name="android.permission.CALL_PHONE">

Another example to launch an intent to open the browser and navigate to a certain URL:

Intent in=new Intent(Intent.ACTION_VIEW, Uri.parse(""));

For a list of available phone actions, check this link

Intent Filters:

Android components like activities can also serve implicit intents. but to do so they have to filter all implicit intents in order to serve only the intents they desire to serve. this is done using intent filters.

Suppose you want  to create an activity that acts as the default dialer activity. You must associate an intent filter with this activity in order to that this activity serve the dial intents only.

Let’s demonstrate a simple example which is creating an application with one activity that we want to make it a dialer activity.

Create a new android project, create an activity and name it Dialer.

In the AndroidManifest.xml file of this application add the following to the Dialer activity:

<intent-filter android:priority="100" >
            <action android:name="android.intent.action.DIAL"  />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:scheme="tel"/>

to become:

<activity android:name=".Dialer"
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            <intent-filter android:priority="100" >
            <action android:name="android.intent.action.DIAL"  />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:scheme="tel"/>

Now what we have done is adding an intent filter to that activity. this intent filter has the following properties:

  1. Action: the type of implicit intents that this activity responds to. in our case it is the dial action. higher numbers represent higher priority.
  2. Priority: about the priority of that activity over other activities that respond to the same type of intents.
  3. Category: Implicit intents have built-in categories. in order that an implicit intent be captured by our activity, the implicit intent category must match our activity category.
  4. Data: adds data specification scheme to the intent filter.

So if any other application has the following module to launch the dialer:

Intent in=new Intent(Intent.ACTION_DIAL, Uri.parse("tel:000"));

The user will see the following dialog offering him/her the choice between the default dialer and our custom dialer.

That is is for implicit intents and intent filters. In the next post we’re going to explore another type of intents which is explicit intents.

examsheets – – – selftestengine ccna exam questionscertkiller – –

6 Responses to “Android App Development: Intents and Intent filters”

  1. Thirumal 29. Feb, 2012 at 8:22 am #

    Nice Article…

  2. Jason 27. Jun, 2012 at 7:44 pm #

    Is it possible that once i click on a dial button, a call will be automatically be made? I am trying to implement what you are teaching into my own customized dialer app, a simple one though. I had created the number buttons, edittext and a dial button… But i do not know how to make it dial when i click on the dial button. So far the numbers can be displayed in the edittext.

  3. Mickey 12. Jul, 2012 at 3:01 am #

    Thank you very much. I didn’t understand implicit intent and intent filter after reading on android developer but this article makes different. thanks again

  4. Mani 13. Sep, 2012 at 11:24 pm #

    nice article….now i understand how implicit intents work but there is some problem..
    when i tried this same code in my application application got crashed ..will you plz tell whats going wrong in my app..


  1. GQAdonis » Simple Article on Android Intents and Filters - 22. Feb, 2011

    [...] Article on Android Intents and Filters TweetThis article is a great introduction to the Android concept of Intents and Intent Filters. Posted on February [...]

  2. Blue Ray Plus - Latest Technology News - 03. Aug, 2012

    Android App Development: Intents and Intent filters…

    Thank you for submitting this cool story – Trackback from Blue Ray Plus – Latest Technology News…

Leave a Reply

© 2008-2051 • Mobile Orchard and the Bar-Tree Logo are service marks. ContactAdvertise