I\'ve got an Android application which needs to be woken up sporadically throughout the day.
To do this, I\'m using the AlarmManager to set up a PendingIntent and ha
This BroadcastReceiver then starts an Activity to bring the UI to the foreground.
This may be the crux of your problem here. Try overriding onNewIntent()
and seeing if the Intent
passed to it has your extra. If so, that's because of the way you set up the activity in the manifest (e.g., you're using singleTop
) and the fact that, in this specific case, the activity already existed.
You might also consider getting rid of i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
and see if that changes matters.
The upshot is that what you're doing -- putting the extra in the Intent
for startActivity()
-- should work just fine. In fact, you can see examples of that here. This suggests it's something funky about the activity (e.g., singleTop
) or the way you're invoking the activity (e.g., FLAG_ACTIVITY_NEW_TASK
).
EDIT:
Since my first shots didn't work, and given your "curiouser" comment above...
This feels a bit like a PendingIntent
-- with those, unless you take steps, you will not be able to update extras.
On a whim, try adding a second
to your activity in the manifest, just on some unique action string, and try starting your activity from your receiver using that. Or, just toss some action string into your Intent
that the receiver is using for startActivity()
, without messing with the manifest.