I am trying to understand from the API the purpose of PendingIntent
.
Sometimes some methods I use requires this, I still did not get the idea right.
Can anyone could explain? why can't i just use context?
Thanks,
moshik
A Pending Intent specifies an action to take in the future. It lets you pass a future Intent to another application and allow that application to execute that Intent as if it had the same permissions as your application, whether or not your application is still around when the Intent is eventually invoked.
So there is no actual difference between the two.
The application specifies a PendingIntent callback (typically an IntentService) which will be called with an intent when activities are detected. The intent recipient can extract the ActivityRecognitionResult using ActivityRecognitionResult.
A PendingIntent
is a combination of a gross action (start an activity? start a service? send a broadcast?), the action details (in the form of an Intent
), and a Context
. The PendingIntent
is handed to the operating system, which will perform the gross action on the Intent
at some future point (hence, "pending"). The Context
is for security -- Android will execute the PendingIntent
with only the permissions of the Context
, so a PendingIntent
cannot access things that the Context
requesting it cannot.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With