我遇到了alarmManager
的問題,以及與此相關的臨時意向。如何正確傳遞唯一的額外信息給未決意圖?
如果我設置了多個警報,它們會熄滅,但附加保持不變。
我已經讀到這些問題:
- android pending intent notification problem
- Android keeps caching my intents Extras, how to declare a pending intent that keeps fresh extras?
,我曾嘗試:
- 分配一個唯一的ID給每個掛起的意圖和
- 使用所有懸而未決的意圖標誌,
都無濟於事。我不知道爲什麼它不起作用。
下面的代碼片段:
Intent intent = new Intent(con,
AppointmentNotificationReciever.class);
intent.putExtra("foo", bar.toString());
int id = randomNum;
PendingIntent sender = PendingIntent.getBroadcast(con, id,
intent, PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager am = (AlarmManager) con.getSystemService(Context.ALARM_SERVICE);
am.set(AlarmManager.RTC_WAKEUP, scheduleExecution, sender);
在我未決的意圖,我嘗試設置PendingIntent.FLAG_UPDATE_CURRENT,但現在當意圖被調用時,我得到一個錯誤,如「java.lang.IllegalArgumentException:不能在這裏使用FLAG_RECEIVER_BOOT_UPGRADE」 - 不知道雖然這個BOOT在哪裏國旗來自,所有我加入了FLAG_UPDATE_CURRENT。你之前有過類似的問題嗎? (我在華爲Ideos 2.2上) – 2011-05-08 03:55:47