我有一個alarmManager
,我用它在特定的時間向用戶發送通知。由於存在多個警報,因此我創建了多個待處理的意圖,並提供了唯一的ID。但是,在某些情況下,我需要獲取所有待處理意圖,然後取消它們,以便重置警報。我已經嘗試過這樣做了,但我仍然無法做到,所以我有幾個問題:如何獲取和取消PendingIntent?
這是您如何正確取得和取消PendingIntent
?
Intent intent = new Intent(con, AppointmentNotificationReciever.class);
PendingIntent sender = PendingIntent.getBroadcast(con, id, intent,
PendingIntent.FLAG_CANCEL_CURRENT);
AlarmManager am = (AlarmManager) con.getSystemService(Context.ALARM_SERVICE);
am.cancel(sender);
意圖是否需要完全匹配原始未決意圖(extras和all)的意圖?
PendingIntent
標誌是否需要匹配原始未決意圖的標誌?
「FLAG_CANCEL_CURRENT」不會有什麼區別 - 對於一個非常出色的分析,請參閱[this](http://justanapplication.wordpress.com/tag/flag_cancel_current/#PendingIntentMatching) – 2013-05-26 13:49:16