我不得不從通知欄在onCreate
刪除未接電話,怎麼過將所有「未讀」「讀」是不夠的清除錯過了通知欄通話
public void resetMissingCalls() {
Runnable reset = new Runnable() {
@Override
public void run() {
String[] projection = { CallLog.Calls._ID,
CallLog.Calls.CACHED_NUMBER_LABEL, CallLog.Calls.TYPE };
String where = CallLog.Calls.TYPE + "=" + CallLog.Calls.MISSED_TYPE
+ " AND " + CallLog.Calls.NEW + "=1";
Cursor c = getContentResolver().query(
CallLog.Calls.CONTENT_URI, projection, where, null, null);
Utils.PrintInfo("CALLS " + c.getCount());
c.moveToFirst();
if (c.getCount() > 0) {
do {
Utils.PrintInfo(c.getString(c
.getColumnIndex(CallLog.Calls._ID)) + " coursor "+c.getString(c
.getColumnIndex(CallLog.Calls.CACHED_NUMBER_LABEL)));
setAsRead(c.getString(c
.getColumnIndex(CallLog.Calls._ID)));
} while (c.moveToNext());
}
c.close();
}
};
new Handler().post(reset);
}
如何清除這個不使用NotificationManager.cancelAll()
NotificationManager notifManager= (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
notifManager.cancelAll();
您是否獲得ID爲您需要刪除通知? – 2014-10-20 09:26:37
nope即時消息不,但也許我可以但我不知道如何從通知本身得到id – Mariusz 2014-10-20 09:33:43
您可以使用[getActiveNotification](http://developer.android.com/reference/android/service/notification/NotificationListenerService.html#getActiveNotifications %28%29),解析您收到的數據,並檢查確定是否有未接電話通知的方式,然後取消該通知。 – 2014-10-20 09:38:38