![]() ![]() 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. 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.
0 Comments
Leave a Reply. |