Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Knowing about Sticky intent in Android

Tags:

android

In android there are 3 kinds of Intents,

  1. Intent,
  2. Sticky Intent,
  3. Pending intent.

so What is sticky intent?

like image 314
Shetty Suresh Babu. Avatar asked Sep 25 '14 12:09

Shetty Suresh Babu.


People also ask

What is the best approach to sticky broadcasts?

Calling the "sendStickyBroadcast" method within an app will cause a Sticky Broadcast message that will stay around within the system for receipt by other classes.

What is Broadcast_sticky?

<uses-permission android:name="android. permission. BROADCAST_STICKY"/> - Allows an application to broadcast sticky intents. android android-intent. Follow this question to receive notifications.

Is initial sticky broadcast Android?

A sticky broadcast is a tool Android developers use for communicating between apps. These broadcasts happen without the user being notified. The Android OS normally treats each application as if it were a separate user.


2 Answers

Intent - is a message passing mechanism between components of Android, except for Content Provider. You can use Intent to start any component.

Sticky Intent - Sticks with Android, for future broadcast listeners. For example if BATTERY_LOW event occurs then that Intent will stick with Android so that any future requests for BATTERY_LOW, will return the Intent.

Pending Intent - If you want some one to perform any Intent operation at future point of time on behalf of you, then we will use Pending Intent.

like image 120
Arun Antoney Avatar answered Sep 16 '22 11:09

Arun Antoney


An intent that is used with sticky broadcast, is called as sticky intent. This intent will stick with android system for future broadcast receiver requests.

OR

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). One example of a sticky broadcast sent via the operating system is ACTION_BATTERY_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 changes in the battery.

like image 30
Umair Avatar answered Sep 16 '22 11:09

Umair