Calling App in Android – Know the required methods to enable call feature in your app

FREE Online Courses: Enroll Now, Thank us Later!

The second important feature among the three features that we know is the Calling by Android. When we are at some distance from our near and dear ones and can’t be with them. All that we do is make a phone call to them.
Android provides us this facility to add the feature of call in our application. In this article, we will be discussing the feature of the Calling app in Android. Also, we will see how we can add this calling service in our Android Application with an example.

Android lets us place a call using the built-in application. This app is very easy to use and can make a call to whoever we want. Nonetheless, it also lets us provide users with the feature of placing calls through our app. We can make calls from our applications by using the built-in application Intent for calling. We use action Intent for this, which is ACTION_CALL.

Get to know in detail about Android Intents with DataFlair.

When we use the intent object ACTION_CALL and pass proper data to it, it helps us to launch the built-in phone call application to make a phone call. Did you ask How?

How to Make Calling App in Android?

Okay, that is quite as simple as I am showing in the following:

  • Action in Intent to Make a Phone Call

We know the action that we will use is ACTION_CALL.

And we will use the following syntax and write it like this to add action call:

Intent myIntent = new Intent(Intent.ACTION_CALL); // this is for Action_call

Or we can also use ACTION_DIAL if we want to get the number from the user and then place a call.

Intent myDialIntent = new Intent(Intent.ACTION_DIAL); // this is for Action_Dial
  • Data in Intent to Make a Phone Call

Now, suppose we want to make a phone call to a given number say -91-1234567890. We will set the number using setData in tel: as URI like shown below:


And if we want to take the number from the user, we will use the getData from the user


Common Calling Scenarioscalling scenarios in android

While we make use of ConntectionService API we also interact with some other classes of android.telecom package. Let us see some of the common calling scenarios and how apps use the API to handle them. There are three scenarios that are:

1. Answer the Call

To handle incoming calls we need to consider if other apps are on call or not. It’s so because the telecom subsystem establishes some constraints when there are active calls in other apps. Consider the following two cases:

A. No Other App on Call

  • Your App receives a call.
  • Call addNewIncomingCall(PhoneAccountHandle, Bundle) to inform the telecom subsystem about it.
  • This subsystem binds to your app’s ConnectionService implementation. It then requests a new instance of the Connection class using, onCreateIncomingConnection(PhoneAccountHandle, ConnectionRequest).
  • This subsystem informs the app to show incoming calls to users using onShowIncomingCallUi().
  • Call setActive() if the user accepts the incoming call. If not, setDisconnected(DisconnectCause) specifying REJECTED as parameter, is followed by the Destroy() method.

B. Other App has Active Call that can’t be Put on Hold

To answer a call while a call that can’t be put on hold is going on, follow the following:

  • Incoming call receives a new call.
  • Call addNewIncomingCall(PhoneAccountHandle, Bundle) to inform the telecom subsystem about it.
  • This subsystem binds to your app’s ConnectionService implementation. It then requests a new instance of the Connection object using, onCreateIncomingConnection(PhoneAccountHandle, ConnectionRequest).
  • The telecom subsystem displays the incoming call on UI.
  • If the user accepts the call, this subsystem invokes the onAnswer() method. To indicate the telecom subsystem, we will call setActive().
  • If the user rejects the call, this subsystem invokes the onReject() method. We will call setDisconnected(DisconnectCause) and pass REJECTED as parameter.
  • And we will call the Destroy() method.

2. Place a Call

While dealing with the process of placing a call, we need to handle the possibility that the call cannot be connected because of some constraints imposed by the telecom framework.

In order to place a call we need to follow the following:

A. Initiate a call from the application.

B. Use the method placeCall(call, bundle) and inform the telecom subsystem about the new call. Now pass the parameters as following:

  • The Uri parameter represents the address of the callee. For numbers use tel:
  • The Bundle: parameter provides information about the application. It’s done by adding the PhoneAccountHandle object of the app to EXTRA_PHONE_ACCOUNT_HANDLE extra.
  • The Bundle: parameter can also specify if it includes video by specifying EXTRA_START_CALL_WITH_VIDEO_STATE .
  • This telecom subsystem binds to the app’s ConnectService implementation.

a. If the app is unable to call, the subsystem invokes onCreateOutgoingConnectionFailed(PhoneAccountHandle, ConnectionRequest). It informs the app that the call can’t be placed.

b. If the app is able to call, it invokes onCreateOutgoingConnectionFailed(PhoneAccountHandle, ConnectionRequest). It informs the app that the call can’t be placed.

  • After the call is active, invoke setActive() to inform the telecom subsystem about the same.

3. End a Call

After the call is connected we would need to end the call, and to end it:

  • Call the method setDisconnected( DisconnectCause).
  • If the call is terminated by the user LOCAL is passed as parameter. REMOTE is passed if the call is disconnected by a third party.
  • After that call the destroy() method.

Implementation of Calling App in Android in Our Application

Step 1: First of all we will create a new project and fill in the details. Then we will open the activity_main.xml file, and define the layout as follow:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android=""
   android:orientation="vertical"    android:layout_width="match_parent"

       android:text="DataFlair "
       android:textSize="50dp" />

       android:text="Please Enter the Mobile No"
       android:textSize="20dp" />

       android:hint="Enter the number here"

       android:text="Dial" />

Step 2: Now we will do the coding for the working in file. We will write the following code:

package com.DataFlair.callexample;

import android.Manifest;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class MainActivity extends AppCompatActivity {
   private EditText text_Phone;
   private Button b_utton;
   protected void onCreate(Bundle savedInstanceState) {
       text_Phone = (EditText) findViewById(;
      mybutton = (Button) findViewById(;
      mybutton.setOnClickListener(new View.OnClickListener() {
           public void onClick(View v) {
   public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
       if (requestCode == 101) {
           if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
   public void callPhoneNumber() {
       try {
           if (Build.VERSION.SDK_INT > 22) {
               if (ActivityCompat.checkSelfPermission(this, Manifest.permission.CALL_PHONE) !=PackageManager.PERMISSION_GRANTED) {
                   ActivityCompat.requestPermissions(MainActivity.this, new String[]{
                   Manifest.permission.CALL_PHONE}, 101);
               Intent callIntent = new Intent(Intent.ACTION_CALL);
               callIntent.setData(Uri.parse("tel:" + text_Phone.getText().toString()));
           } else {
               Intent callIntent = new Intent(Intent.ACTION_CALL);
               callIntent.setData(Uri.parse("tel:" + text_Phone.getText().toString()));
       } catch (Exception ex) {

Step 3: Now we will update the Manifest.xml file, as follow:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=""
   <uses-permission android:name="android.permission.CALL_PHONE" />
       <activity android:name=".MainActivity">
               <action android:name="android.intent.action.MAIN" />
               <category android:name="android.intent.category.LAUNCHER" />
           android:resource="@array/preloaded_fonts" />

Step 4: Now we will run the application as follows:

i) The app will look like this:calling app in android

ii) Then we will enter a number:enter number in android

iii) As soon as we will press Dial, it will ask for permission and we will allow it.allow permission to do calling

iv) After that, the Call would be call in android calling app


In this article, we are done with the feature of the Calling app in Android. We have seen how we can implement calling in our application. We have also seen the required methods for enabling the call feature in our app. Now it is your turn to implement and let me know. In the next article, we will see the email feature of Android.

If you have any queries regarding DataFlair’s Calling App in Android article, mention them in the comment section.

Happy Learning😃

Did you know we work 24x7 to provide you best tutorials
Please encourage us - write a review on Google

follow dataflair on YouTube

5 Responses

  1. Brijpal says:

    Dear sir thanks for providing huge information abut app to app calling. Dear sir I just asked is there any type of charges to make call app to app and should we required any third party service to build function in android app to call app to app.

  2. Anthony says:

    Hola, quiero saber si hay manera de obtener fecha, hora inicial y hora finalizada de la llamada. ya que quiero guardar esa información en mi bd.

  3. Barsha sahu says:

    Very good app

  4. Annie says:

    you literally failed stackoverflow, greekforgeek, and many more I tried each of their code but doesn’t work for me, but only your work, thanks a lot 🙂

  5. praveen kispotta says:

    Where is PhoneAccountHandle and TelecomManager ? How to register PhoneAccount ?

Leave a Reply

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