Monday, June 24, 2013

Detect Missed Call In Android

How to detect a Missed Call in Android

Prerequisite:You should know how to handle Incoming Call. if not, read the post  Handle Incomig Calls using BroadCastReceiver

How to approach :
whenever there as an incoming Phone goes in "RINGING" state, and if the person has not picked/received the call Phone Rings till a particular time and then goes in "IDLE" state.   So we have to monitor the Phone State and check the State accordingly.

Permission Required: 

Following permission is required to listen/monitor the Phone State.
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
Declare the above permission in manifest file.

Listening Phone State:

We use a BroadcastReceiver class that will monitor the Phone State, whenever there is a change in Phone State, the onReceive() method of BroadcasrReceiver will be called, and in onReceivee(),  we check for the condition, See the Code below

do not forget to register the BroadcastReceiver in manifest  (see the manifest file at the bottom )

public class IncommingCallReceiver extends BroadcastReceiver
      static boolean ring=false;
      static boolean callReceived=false;
      public void onReceive(Context mContext, Intent intent)
             // Get the current Phone State
            String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);

            // If phone state "Rininging"
                      ring =true;
                     // Get the Caller's Phone Number
                     Bundle bundle = intent.getExtras();
                     callerPhoneNumber= bundle.getString("incoming_number");

             // If incoming call is received

             // If phone is Idle
            if (state.equals(TelephonyManager.EXTRA_STATE_IDLE))
                      // If phone was ringing(ring=true) and not received(callReceived=false) , then it is a missed call
                                Toast.makeText(mContext, "It was A MISSED CALL from : "+callerPhoneNumber, Toast.LENGTH_LONG).show();

 Your manifest should look like follows

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=""
    android:versionName="1.0" >

        android:targetSdkVersion="16" />
       <!--  declare the permission -->
        <uses-permission android:name="android.permission.READ_PHONE_STATE" />

        android:theme="@style/AppTheme" >
        <!-- Register the Broadcast receiver  -->
        <receiver android:name=".IncommingCallReceiver" android:enabled="true">
                    <action android:name="android.intent.action.PHONE_STATE" />



  1. Its simple and clean example. Thanks!

  2. Thanks, it works great. But I need also unanswered outgoing calls. Is it possible to detect it via BroadcastRecevier and how?

  3. Hi, good example. But you need to reset the vars during ringing and after missed call for the next call.

  4. this code not woking on my their any settings.?

  5. what should i pass in the Intent parameter when i call this function in my activity...please help

    1. No need to pass anything, onReceive() will be called itself with the intent.

    2. hi, there is nothing happen with me.while i used above code.
      its giving....... No Launcher activity found! & The launch will only sync the application package on the device!
      in console.what to do

  6. what should i pass intent parameter while calling this function in activity

  7. If i wanted more data about the incoming call ... say if nothing was in contacts for a incoming call ... where would I look to see what else came with intent.getExtras(); into our bundle?

  8. thank you it's nice n very useful example

  9. Your code is correct but you should use this snippest for idle state then it will give perfect answer

    // phone is idle
    if (state.equals(TelephonyManager.EXTRA_STATE_IDLE)) {
    // detect missed call
    if (isRinging == true && isReceived == false) {
    “Got a missed call from : ” + callerPhoneNumber,

    Toast.makeText(mContext, “Missed”, Toast.LENGTH_LONG).show();

    isRinging = false;
    isReceived = false;

    you need to false boolean variable in idle state condition else it will cause a bug

    BUG–>if i got missed call then 2nd if i receve d call then 3rd if i missed d call then this scenario will not able to capture thru ur code so use my above snippest in ur code then it will work fyne in all scenario

  10. this is work fine for my app but not working whenever application is not running any solution for that???

  11. nothing is happening here.And it is showing
    No Launcher activity found!
    The launch will only sync the application package on the device!

    what to do

  12. hi solveed that problem can i get name if the no is saved in my contact list