When to use IntentSender vs PendingIntent?

The Android documentation describes both PendingIntent and IntentSender , but it is not clear when or why you would use IntentSender over a PendingIntent - in fact, most of the description seems identical for both.

PendingIntent Documentation:

Description of the Intent and target action to perform with it. Instances of this class are created using (...); the returned object can be transferred to other applications in order to subsequently perform the action described by you on your behalf.

IntentSender Documentation:

Description of the Intent and target action to perform with it. The returned object can be transferred to other applications so that they can perform the action that you described on your behalf later.

Both Parcelable classes and both classes allow the receiver to invoke an action using send or sendIntent (with almost identical signatures).

Since there is an existing PendingIntent to create an PendingIntent , in what situation would you like to create an IntentSender rather than just using a PendingIntent ?

+8
android android-pendingintent
source share
1 answer

There are really good examples and explanations here .

Here is a brief summary:

IntentSender

IntentSender is an instance of android.content.IntentSender

IntentSender instances cannot be built directly, but they can be obtained from the android.app.PendingIntent instance with PendingIntent.getIntentSender() , because PendingIntent encapsulates IntentSender .

IntentSender Documentation

Pendingintent

A PendingIntent is a token that you specify to a foreign application (for example, AlarmManager or AppWidgetManager ), which allows a foreign application to use the permissions of your application to execute a predefined piece of code.

Basically, the foreign application that receives the PendingIntent does not know the contents of the Intent that is wrapped by PendingIntent , but the foreign application should send a request to the main application when the certai conditions are met.

PendingIntent Documentation

-2
source share

All Articles