Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android get Missed call

Tags:

android

So I want to get the count of the missed calls like the telephonyapplication displays in the notification bar

so I came up with this code :

String[] projection = { CallLog.Calls.CACHED_NAME, CallLog.Calls.CACHED_NUMBER_LABEL, CallLog.Calls.TYPE };
String where = CallLog.Calls.TYPE+"="+CallLog.Calls.MISSED_TYPE;          
Cursor c = this.getContentResolver().query(CallLog.Calls.CONTENT_URI,projection,where, null, null);
c.moveToFirst();    
Log.d("CALL", ""+c.getCount()); //do some other operation

if(c.getCount() > 0)//...etc etc
    Toast.makeText(app.this,String.valueOf(c.getCount()), Toast.LENGTH_LONG).show(); 

This code gives me the toatl amount of missed calls but I want only the newest calls which are displayed in the notification bar

has anybody an idea how to do that ?

like image 816
user1426956 Avatar asked Dec 29 '25 00:12

user1426956


1 Answers

CallLog.Calls also has IS_READ and NEW fields.

I believe that you should add to your where string - IS_READ = 0 .

Note that IS_READ is from API Level 14 and NEW is from API Level 1, so I would check them both.

http://developer.android.com/reference/android/provider/CallLog.Calls.html#IS_READ

like image 191
Ran Avatar answered Jan 02 '26 19:01

Ran



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!