What is a Sticky Intent?

479 views.

What is a Sticky Intent?

Add Comment
1 Answer(s)
452 views.

Sticky Intent is also a type of Intent which allows a communication between function and a service sendStickyBroadcast() performs a sendBroadcast(Inent) know as sticky,the Intent your are sending stays around after the broadcast is complete, so that others can quickly retrieve that data through the return value of registerReceiver(BroadcastReceiver, IntentFilter). In all other ways, this behaves the same as sendBroadcast(Intent).

One example of a sticky broadcast sent via the operating system is ACTION_BATTARY_CHANGED.When you call registerReceiver() for that action — even with a null BroadcastReceiver — you get the Intent that was last Broadcast fot that action. Hence, you can use this to find the state of the battery without necessarily registering for all future state change in the battery.

Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.