Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When would you use PendingIntent?

Tags:

android

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

like image 409
Moshik Avatar asked Apr 24 '10 15:04

Moshik


People also ask

Why would you use a PendingIntent?

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.

What is the difference between intent and PendingIntent?

So there is no actual difference between the two.

What is PendingIntent callback?

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.


1 Answers

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.

like image 162
CommonsWare Avatar answered Sep 18 '22 16:09

CommonsWare