I am setting an alarm on a button click.
The alarm is triggered with an intent.
This intent get an extra "int" to pass to the Broadcast Receiver.
The problem is that the intent's extra gets set once on the first click of the button and never changes on the other clicks:
Intent intent = new Intent(A.this, B.class);
intent.putExtra(WAKEUP_DURATION, wakeUpDuration);
PendingIntent sender = PendingIntent.getBroadcast(A.this, 0, intent, 0);
I tried removing it in the Broadcast Receiver, but no luck:
intent.removeExtra(A.WAKEUP_DURATION);
Thanks! That did the trick. For those of you who would like to know the exact answer. The "FLAG_UPDATE_CURRENT" goes as the fourth argument in the method 'getBroadcast'. It should look like this:
Use
FLAG_UPDATE_CURRENT
when creating yourPendingIntent
to update the extras from a newIntent
.