开发者

Editing an alarm !

I am setting an alarm for my reminder app:

PendingIntent sender = PendingIntent.getBroadcast(AddToDoList.this, 
          Integer.parseInt(DBHelperClass.getMaxPrimaryId()), intent, 0);开发者_运维问答

i am using a unique value (primary ID) to set an alarm. When i want to edit the alarm i am using the same key. But what i see is that both the alarms go off! original as well as edited one.

how do i cancel the old alarm ? Also these alarms are not working once i switchOff & then again switchOn my device .


how do i cancel the old alarm ?

Call cancel() with your original PendingIntent.

Also these alarms are not working once i switchOff & then again switchOn my device .

Alarms do not persist after a reboot. You will need to reschedule the alarms, possibly by a BroadcastReceiver that gets control at boot time.


You should consider changing the way you make Intents unique - requestCode is not officially defined. Try keeping Intent's data different for example.

About persisting the alarm trough reboots, I'm not sure but maybe RTC_WAKEUP flag is the closest you can get.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜