Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

broadcast receiver for missed call in android

Does anyone know what is the intent for missed call. Actually i want to send sms on missed call and incomming call in my application.

like image 805
Sujit Avatar asked Sep 08 '10 06:09

Sujit


People also ask

How do I get my Android to show missed calls?

See your call historyOpen your device's Phone app . Tap Recents . You'll see one or more of these icons next to each call in your list: Missed calls (incoming) (red)

How do I receive missed call messages?

Settings. Under Messages, Calls, or Voicemail, tap the notification setting: Message notifications. Missed call notifications.


2 Answers

You need to use a ContentObserver

public class MissedCallsContentObserver extends ContentObserver
{
    public MissedCallsContentObserver()
    {
        super(null);
    }

    @Override
    public void onChange(boolean selfChange)
    {
        Cursor cursor = getContentResolver().query(
            Calls.CONTENT_URI, 
            null, 
            Calls.TYPE +  " = ? AND " + Calls.NEW + " = ?", 
            new String[] { Integer.toString(Calls.MISSED_TYPE), "1" }, 
            Calls.DATE + " DESC ");

        //this is the number of missed calls
        //for your case you may need to track this number
        //so that you can figure out when it changes
        cursor.getCount(); 

        cursor.close();
    }
}

From your app, you just need to do this:

MissedCallsContentObserver mcco = new MissedCallsContentObserver();
getApplicationContext().getContentResolver().registerContentObserver(Calls.CONTENT_URI, true, mcco);
like image 129
Joe Avatar answered Oct 08 '22 14:10

Joe


There is no specific broadcast for a missed call, AFAIK.

You can watch for ACTION_PHONE_STATE_CHANGED broadcasts, wait until the phone shifts from EXTRA_STATE_RINGING to EXTRA_STATE_IDLE, then try checking the CallLog content provider to see if the call was missed. I have not tried this technique, but it may work.

like image 42
CommonsWare Avatar answered Oct 08 '22 13:10

CommonsWare