What is Intent vs Sticky Intent vs Pending Intent?

Technology CommunityCategory: AndroidWhat is Intent vs Sticky Intent vs Pending Intent?
VietMX Staff asked 3 years ago

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. 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).

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.

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.