If an Activity calls onPause
with a normal broadcast, receiving the Broadcast can be missed. A sticky broadcast can be checked after it was initiated in onResume
.
Sticky broadcasts are deprecated.
See sendStickyBroadcast
documentation.
This method was deprecated in API level 21.
Sticky broadcasts should not be used. They provide no security (anyone can access them), no protection (anyone can modify them), and many other problems. The recommended pattern is to use a non-sticky broadcast to report that something has changed, with another mechanism for apps to retrieve the current value whenever desired.
Intent intent = new Intent("some.custom.action");
intent.putExtra("some_boolean", true);
sendStickyBroadcast(intent);
Related post: What is the difference between sendStickyBroadcast and sendBroadcast in Android?
See removeStickyBroadcast(Intent)
, and on API Level 5 +, isInitialStickyBroadcast()
for usage in the Receiver's onReceive
.