android - How can I correctly pass unique extras to a pending intent? -
i'm having problem alarmmanager
, pending intent extras go along it.
if set multiple alarms, go off, extras stay same.
i have read these questions:
- android pending intent notification problem
- android keeps caching intents extras, how declare pending intent keeps fresh extras?
and have tried:
- assigning unique id each pending intent ,
- using pending intent flags,
all no avail. have no clue why not work.
here code snippet:
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 = (alarmmanager) con.getsystemservice(context.alarm_service); am.set(alarmmanager.rtc_wakeup, scheduleexecution, sender);
possibly 2 different issues here:
1) if you've created pendingintent before , "matches" existing pendingintent, must specify pendingintent.flag_update_current flag or not pass extras. "match" based on criteria intent.filterequals() uses, read docs there , make sure understand data, action, type, etc.
2) i've read if not set action on intent, not propagate extras, perhaps try intent.setaction("com.blah.action").
Comments
Post a Comment