Additional intentions are not deleted / not replaced

I set the alarm by pressing a button.

An alarm is triggered with intent.

This intent gets an extra "int" to transmit to the broadcast receiver.

The problem is that the intention is additionally set once on the first click of a button and never changes on 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 with no luck:

intent.removeExtra(A.WAKEUP_DURATION);
+3
source share
2 answers

Use FLAG_UPDATE_CURRENTwhen creating PendingIntentto update additional features from a new one Intent.

+8
source

! . , . "FLAG_UPDATE_CURRENT" getBroadcast. :

PendingIntent sender = PendingIntent.getBroadcast(A.this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
+5

All Articles