Android Intents: part 1

Public on June 24, 2010
In this post we are going to explore the concept of intents in Android.

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 peice 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 autom atically you could have used this intent
but this requires ading the following permission to the manifest file:
<uses-permission android:name="android.permission.CALL_PHONE">
and that was how to launch the phone activities using intents.
for a list of available phone actions, check this link

[Advertising]Faster Thinking - Speed up your brain

Faster Thinking Game

sentiment_satisfied Emoticon