Open top menu

Why we are used Sticky Intent in android?

Sticky intents are associated with the android system for the future broadcast events. The android system used sticky broadcast for certain system information .for example the batter status is send as sticky intent and can received at any time. For example

// Register for the battery changed event

IntentFilter filter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);

Intent batteryStatus = this.registerReceiver(null, filter);

Stick intent is also a type of intent which allows a communication between function and service sendStickyBroadcast() perform a sendBroadcast(intent) know as sticky.

A sticky broadcast may be removed at any time via a call to the  removeStickyBroadcast() method, passing through as an argument a reference to the broadcast intent to be removed.