Search code examples
androidtelephony

Android - remove missed call notification


is there anyway to remove a missed call notification by code? And somehow remove the last missed call from call history?


Solution

  • yes, it is possible.Try this:

    Uri UriCalls = Uri.parse("content://call_log/calls");
    Cursor cursor = getApplicationContext().getContentResolver().query(UriCalls, null, null, null, null);
    

    Reading call log entries...

    if(cursor.getCount() > 0){
        cursor.moveToFirst();
        while(!cursor.isAfterLast()){
            String number = cursor.getString(cursor.getColumnIndex(CallLog.Calls.NUMBER)); // for  number
            String name = cursor.getString(cursor.getColumnIndex(CallLog.Calls.CACHED_NAME));// for name
            String duration = cursor.getString(cursor.getColumnIndex(CallLog.Calls.DURATION));// for duration
            int type = Integer.parseInt(cursor.getString(cursor.getColumnIndex(CallLog.Calls.TYPE)));// for call type, Incoming or out going
            cursor.moveToNext();
        }
    }
    

    Deleting entry in call log...

    String queryString= "NUMBER='" + number + "'";
    if (cursor.getCount() > 0){
            getApplicationContext().getContentResolver().delete(UriCalls, queryString, null);
    }
    

    Permission:

    <uses-permission android:name="android.permission.WRITE_CONTACTS" />
    <uses-permission android:name="android.permission.READ_CONTACTS" />
    

    Note: Please refer this doc over call log for more clearity.

    Using the above code you can get the desired result.