top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is a Sticky Intent in Andriod?

0 votes
413 views
What is a Sticky Intent in Andriod?
posted Mar 14, 2017 by Karthick.c

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes
 
Best answer

Sticks with android, for future broad cast listeners.

How it works:
sendStickyBroadcast() performs a sendBroadcast(Intent) known as sticky, i.e. the Intent you 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).

Example
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 for 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.

answer Mar 16, 2017 by Salil Agrawal
...