

The calling app will then see the extra EXTRA_CUSTOMER_MESSAGE in its Intent and be able to display the message. The most common, and most basic, way to use a PendingIntent is as the action associated with a notification: val intent = Intent(applicationContext, MainActivity::class.java).apply nd( applicationContext, PENDING_INTENT_CODE, intentWithExtrasToFill )

Let’s take a look at the different ways our apps can work with PendingIntents and why we might want to use them in these ways. In most situations, such as the alarm and notifications, this is the identity of the app itself. In order for the PendingIntent to have the same behavior as if it were a normal Intent, the system triggers the PendingIntent with the same identity as it was created with.

That is, the other app uses your app’s identity when invoking the intent. For example, the wrapped intent might be invoked when an alarm goes off, or when the user taps on a notification.Ī key aspect of pending intents is that another app invokes the intent on your app’s behalf.

What is a PendingIntent?Ī PendingIntent object wraps the functionality of an Intent object while allowing your app to specify something that another app should do, on your app’s behalf, in response to a future action. Since Android 12 includes important changes to pending intents, including a change that requires explicitly deciding when a PendingIntent is mutable or immutable, I thought it would be helpful to talk more what pending intents do, how the system uses them, and why you might occasionally want a mutable PendingIntent. * action The action to be sent via the pending intent.PendingIntents are an important part of the Android framework, but most of the available developer resources focus on their implementation details - a “reference to a token maintained by the system” - rather than their usage. * mbrComponent The full component name of a media button receiver where you want to send * context The context of the application. Private SliceAction fallBackToAppData(Context context, SliceItem texreplacedem, SliceItem iconItem, int iconMode, SliceItem actionItem)
