Search code examples
androidcallandroid-5.0-lollipopandroid-6.0-marshmallowandroid-5.1.1-lollipop

Android M & Lollipop - Mark missed call as read


I use below code to clear missed calls after I launch my app. In this I get rows affeted is 1. But when i get next missed call, at that time android's stock phone app adds a new notification as "2 new missed calls". Means they are not counting my clear. Am I missing something.

Note: If i launch the stock phone app once, the counter is reset to 0 again.

public boolean markMissedCallsAsRead() {
    ContentValues values = new ContentValues();
    values.put(CallLog.Calls.NEW, Integer.valueOf(0));
    values.put(CallLog.Calls.IS_READ, Integer.valueOf(1));
    StringBuilder where = new StringBuilder();
    where.append(CallLog.Calls.NEW);
    where.append(" = 1 AND ");
    //where.append(CallLog.Calls.IS_READ).append(" = 0");
    //where.append(" AND ");
    where.append(CallLog.Calls.TYPE).append(" = ").append(CallLog.Calls.MISSED_TYPE);


        int rows = context.getContentResolver().update(CallLog.Calls.CONTENT_URI, values, where.toString(),
                null);
        Utilities.writeToLogFile(Constants.LOG_ERROR_LEVEL, "cleared call logs " + rows);
        return true;

}

Solution

  • I'm facing the same problem. There is a similar question here: https://stackoverflow.com/a/26564121/6433463

    I'm starting to think (as stated in that thread) that the only way to achieve that is by opening the stock call log (I hope I'm wrong, but couldn't find anything else).