我必须删除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()
答案 0 :(得分:0)
如果您想取消所有通知使用
NotificationManager notifManager= (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
notifManager.cancelAll();
但如果您有通知ID,请使用
notifManager.cancel(notifyId);
如果您想收听Android通知,则需要注册AccessibilityService
您可能需要查看此answer