The Intent
s I broadcast with LocalBroadcastManager
don't seem to be consumed, but instead accumulate. Each time I send a broadcast, I receive both it and all previously sent broadcasts, in onReceive
.
In a periodical JobService
I'm creating a BroadcastReceiver
with an IntentFilter
and registering it dynamically with lbm.registerReceiver(receiver, intentFilter);
. I then start a Service
which creates an Intent
with the same filter in its constructor, and does lbm.sendBroadcast(intent);
once, then stops itself.
sendBroadcast
returns true which should indicate that it was received on the other end (see Is there a way to tell if LocalBroadcastManager broadcasts were received?). However each time this cycle is repeated, all the previously received Intents
are received again. By bundling a timestamp I have confirmed that it's really the old ones just lying around and being received over and over again.
How do I "consume" the received Intent
? From what I can tell this shouldn't be necessary if it was received by onReceive. I don't find any methods for cancelling a broadcast in either Intent
or LocalBroadcastManager
.
How can I receive each broadcast only once?