Android phone calls

Android Phone Calls

As such every Android Device especially Mobile phone is meant to provide a functionality to make a phone call but still you may need to write an application where you want to give an option to your user to make a call using a hard coded phone number.

This chapter lists down all the simple steps to create an application which can be used to make a Phone Call. You can use Android Intent to make phone call by calling built-in Phone Call functionality of the Android. Following section explains different parts of our Intent object required to make a call.

Intent Object – Action to make Phone Call

You will use ACTION_CALL action to trigger built-in phone call functionality available in Android device. Following is simple syntax to create an intent with ACTION_CALL action

Intent phoneIntent = new Intent(Intent.ACTION_CALL);

You can use ACTION_DIAL action instead of ACTION_CALL, in that case you will have option to modify hardcoded phone number before making a call instead of making a direct call.

Intent Object – Data/Type to make Phone Call

To make a phone call at a given number 91-800-001-0101, you need to specify tel: as URI using setData() method as follows:


The interesting point is that, to make a phone call, you do not need to specify any extra data or data type.


Following example shows you in practical how to use Android Intent to make phone call to the given mobile number.

To experiment with this example, you will need actual Mobile device equipped with latest Android OS, otherwise you will have to struggle with emulator which may not work.





You will use Eclipse IDE to create an Android application and name it as PhoneCallDemo under a packagecom.example.phonecalldemo. While creating this project, make sure you Target SDK and Compile With at the latest version of Android SDK to use higher levels of APIs.


Modify src/ file and add required code to take care of making a call.


Modify layout XML file res/layout/activity_main.xml add any GUI component if required. I’m adding a simple button to Call 91-800-001-0101 number


Modify res/values/strings.xml to define required constant values


Modify AndroidManifest.xml as shown below


Run the application to launch Android emulator and verify the result of the changes done in theaplication.

Following is the content of the modified main activity file src/com.example.phonecalldemo/

package com.example.phonecalldemo;
import android.os.Bundle;
import android.content.Intent;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
public class MainActivity extends Activity {
   protected void onCreate(Bundle savedInstanceState) {
      Button startBtn = (Button) findViewById(;
      startBtn.setOnClickListener(new View.OnClickListener() {
         public void onClick(View view) {
   protected void makeCall() {
      Log.i("Make call", "");
      Intent phoneIntent = new Intent(Intent.ACTION_CALL);
      try {
         Log.i("Finished making a call...", "");
      } catch (android.content.ActivityNotFoundException ex) {
         "Call faild, please try again later.", Toast.LENGTH_SHORT).show();
   public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(, menu);
      return true;

Following will be the content of res/layout/activity_main.xml file:

<LinearLayout xmlns:android=""
   android:orientation="vertical" >
   <Button android:id="@+id/makeCall"

Following will be the content of res/values/strings.xml to define two new constants:

<?xml version="1.0" encoding="utf-8"?>
    <string name="app_name">PhoneCallDemo</string>
    <string name="hello_world">Hello world!</string>
    <string name="action_settings">Settings</string>
    <string name="make_call">Call 91-800-001-0101</string>

Following is the default content ofAndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=""
    android:versionName="1.0" >
        android:targetSdkVersion="17" />
   <uses-permission android:name="android.permission.CALL_PHONE" />
   <uses-permission android:name="android.permission.READ_PHONE_STATE" />
        android:theme="@style/AppTheme" >
            android:label="@string/app_name" >
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />

Let’s try to run your PhoneCallDemoapplication. I assume you have connected your actual Android Mobile device with your computer. To run the app from Eclipse, open one of your project’s activity files and click Run icon from the toolbar. Before starting your application, Eclipse will display following window to select an option where you want to run your Android application.

Selct your mobile device as an option and then check your mobile device which will display following screen:

Now use Call 91942-347-6192 button to make phone call.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s