Mark Missed Calls as read in Android Call Log

1.1k views Asked by At

I am trying to mark the missed calls to read. I am trying the following to do so:

ContentValues values = new ContentValues();    
values.put(Calls.NEW, Integer.valueOf(0));    
if (android.os.Build.VERSION.SDK_INT >= 14){    
   values.put(Calls.IS_READ, Integer.valueOf(1));    
}

StringBuilder where = new StringBuilder();    
where.append(Calls.NEW);
where.append(" = 1 AND ");    
where.append(Calls.TYPE);    
where.append(" = ?");    
ContentResolver cr = getContentResolver();    
Uri baseUri = Uri.parse("content://call_log/calls");    
int numUpdated = cr.update(baseUri, values, where.toString(),new String[]{ Integer.toString(Calls.MISSED_TYPE) });

This actually marks the call read for my app but native android app is not detecting this and still show missed call badge and notification. How can we get this cleared.

2

There are 2 answers

1
HMH On

You can't clear missing call notification. Google disabled access to this functionality to third party apps.

0
Ch4vi On

First add permissions :

<uses-permission android:name="android.permission.READ_CALL_LOG" />
<uses-permission android:name="android.permission.WRITE_CALL_LOG" />

After you insert the function that changes the parameter is_read missed call we get from its id:

public void markCallLogRead(int id) {

    Uri CALLLOG_URI = CallLog.Calls.CONTENT_URI;
    ContentValues values = new ContentValues();
    values.put("is_read", true);
    try{
        getContentResolver().update(CALLLOG_URI, values, "_id=?",
                new String[] { String.valueOf(id) });
    }catch(Exception e){
        e.printStackTrace();
    }

}