Using this code I managed to mark all missed calls as read:
ContentValues values = new ContentValues();
values.put(Calls.NEW, 0);
if (android.os.
The only "legal" but extremely ugly and usually useless way to achieve what you want is to show Call Log to user. And I mean literally show (becomes visual, gets focus). In case you want to do this, here's how:
public static boolean showCallLog(Context context)
{
try
{
Intent showCallLog = new Intent();
showCallLog.setAction(Intent.ACTION_VIEW);
showCallLog.setType(android.provider.CallLog.Calls.CONTENT_TYPE);
context.startActivity(showCallLog);
return true;
}
catch (Exception e)
{
Log.d("Couldn't show call log.", e.getMessage());
}
return false;
}
The reason behind this mess is the fact that apps authoritatively responsible for call logging and notifying users about missed calls (stock phone apps) use cached values. Why? Because of overall performance. You need to somehow notify those apps that Call Log has changed (seen means changed, as well) and that it should update it. It would be nice if all such apps on all devices would receive a broadcast in order to refresh, but as far as I know, it's not the case.
I hope someone will find a better way (without interrupting the user) to force refresh on stock phone apps.
How can I also clear the notification bar for calls in android?
You don't. That Notification
is put there by another app, and you have no means of controlling whether that Notification
is displayed, short of building a ROM mod that changes the behavior of that other app.
UPDATE: Since this answer was originally written, NotificationListenerService
was added and can clear notifications, but only on Android 4.3+.