I read the Android Documentation but I still need some more clarification. What exactly is a PendingIntent
?

- 62,466
- 11
- 102
- 153

- 14,997
- 13
- 42
- 62
18 Answers
A PendingIntent
is a token that you give to a foreign application (e.g. NotificationManager
, AlarmManager
, Home Screen AppWidgetManager
, or other 3rd party applications), which allows the foreign application to use your application's permissions to execute a predefined piece of code.
If you give the foreign application an Intent, it will execute your Intent
with its own permissions. But if you give the foreign application a PendingIntent
, that application will execute your Intent
using your application's permission.

- 237,138
- 77
- 654
- 440

- 62,238
- 13
- 100
- 144
-
5except for notifications, where else have you seen using pendingIntents ? I think I saw only notifications use it... – android developer Jan 29 '14 at 14:14
-
@LieRyan oh sorry for that. may i please delete the post i've written (and you yours) ? also, do you know of other classes that use PendingIntent? – android developer Jan 29 '14 at 17:07
-
13@LieRyan this answer is better than developer.google explanation about pendingintent thx for it – Antwan Feb 28 '14 at 20:01
-
There are precaution on reference page regarding using PendingIntents. Can you please explain what issues may occur while using this PendingIntents? – Johnny_D Mar 02 '14 at 15:23
-
@Johnny_D: which precaution are you referring to? – Lie Ryan Mar 02 '14 at 15:25
-
Second paragraph in description on http://developer.android.com/reference/android/app/PendingIntent.html – Johnny_D Mar 02 '14 at 15:26
-
4@Johnny_D: it means what it says, in general, you would want to create an explicit Intent whose component name is an absolute name that unambiguously refers to one of your own classes. Otherwise, the Intent might get sent to an another application, which may cause problems since that Intent will be running under your application's permission. – Lie Ryan Mar 02 '14 at 15:58
-
4@LieRyan, is application permission here is the permission we specify in the manifest? Eg. INTERNET permission? – Diffy Jun 28 '14 at 05:41
-
2Isn't this "handover of permissions" really bad security-wise? I have an application A that I gave several permissions. Then I have application B which uses a lot less permissions. If application A can start something in application B via a PendingIntent (allowing all permissions from A to be on B temporarily), can't B do whatever it can behind the scenes with that permission? For instance, A might have the permission to read the user's contacts but B does not. If A sends a PendingIntent to B, B can then read the contacts and do something malicious (like send it to a server). – Bitcoin Cash - ADA enthusiast Oct 29 '14 at 02:01
-
6@Tiago: In your case, if a privileged Application A gives Application B a pending intent so that B can send it when it wants to read a contact data. It is the responsibility of A to ask the user which contact data the user wants to give to B, and only give B that data. Pending Intent is a privilege escalation mechanism, and just like any privilege escalation mechanism, with great power comes great responsibility. It is the responsibility of the user to decide whether application B is trustworthy for the contact data the user selected. – Lie Ryan Nov 03 '14 at 10:04
-
@LieRyan "It is the responsibility of A to ask the user which contact data the user wants to give to B, and only give B that data.". I missed that part. That way it is slightly more secure then. I thought app B would be able to loop through all the contacts (with the permission from app A). Thanks for clarifying! – Bitcoin Cash - ADA enthusiast Nov 03 '14 at 20:42
-
@androiddeveloper except notification, you can see usage of pending intent for AlarmManager class where you can schedule a task. – 100RaBH Sep 26 '19 at 05:55
-
@LieRyan can you help me finding serial key for a software ? – Krishna Kanth May 01 '22 at 05:35
Why PendingIntent is required ? I was thinking like
- Why the receiving application itself cannot create the
Intent
or - Why we cannot use a simple
Intent
for the same purpose.
E.g.Intent bluetoothIntent= new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
If I send bluetoothIntent
to another application, which doesn't have permission android.permission.BLUETOOTH_ADMIN
, that receiving application cannot enable Bluetooth with startActivity(bluetoothIntent)
.
The limitation is overcome using PendingIntent
. With PendingIntent
the receiving application, doesn't need to have android.permission.BLUETOOTH_ADMIN
for enabling Bluetooth. Source.

- 2,496
- 26
- 39

- 10,859
- 4
- 50
- 82
-
5
-
2@Kiran - If receiving application can turn on Bluetooth (using Pending Intent) then why that app didn't included this permission in its Manifest? It's like I am making an app that can make a call but I am not including the permission CALL_PHONE because I want other app to send me a Pending Intent to make this call. Is this what you want to say? – CopsOnRoad Jan 04 '18 at 06:55
-
2@CopsOnRoad The receiving app of the PendingIntent can be a general app that receives whatever request and executes the request on the behalf of the requestor. Its role is just a middle-man, hence does not have all the permissions. An example of this kind of middle-man apps is the notification manager, which can launch whatever intended apps from a notification, without owning the permission. – Xiao-Feng Li May 04 '19 at 23:20
-
This is an helpful example. I got a clear understanding about the difference between normal Intent and PendingIntent. Thanks You – Prasanna Kumar Dec 15 '22 at 04:40
A Pending Intent is a token you give to some app to perform an action on your apps' behalf irrespective of whether your application process is alive or not.
I think the documentation is sufficiently detailed: Pending Intent docs.
Just think of use-cases for Pending Intents like (Broadcasting Intents, scheduling alarms) and the documentation will become clearer and meaningful.

- 237,138
- 77
- 654
- 440

- 36,316
- 26
- 109
- 116
-
I think Intent is also a kind of token that we give to some other app to perform an action on our app's behalf. So, the only difference between a Pending intent and Intent is our application process life? – CopsOnRoad Jan 04 '18 at 06:41
In my case, none of above answers nor google's official documentation helped me to grab the concept of PendingIntent
class.
And then I found this video, Google I/O 2013, Beyond the Blue Dot session. In this video, ex-googler Jaikumar Ganesh explains what PendingIntent
is, and that was the thing gave me the big picture of this.
Below is just transcription of above video (from 15:24).
So what's a pending intent?
It's a token that your app process will give to the location process, and the location process will use it to wake up your app when an event of interest happens. So this basically means that your app in the background doesn't have to be always running. When something of interest happens, we will wake you up. This saves a lot of battery.
This explanation becomes more clear with this snippet of code(which is included in the session's slide).
PendingIntent mIntent = PendingIntent.getService(...);
mLocationClient.requestLocationUpdates(locationRequest, mIntent);
public void onHandleIntent(Intent intent) {
String action = intent.getAction();
if (ACTION_LOCATION.equals(action)) {
Location location = intent.getParcelableExtra(...)
}
}

- 11,744
- 6
- 50
- 91

- 15,997
- 9
- 44
- 38
-
Agree, it's quite simple and clear to understand. But it doesn't tell us anything about the permission that PendingIntent gives to other app. – CopsOnRoad Jan 04 '18 at 07:27
Pending intent is an intent which will start at some point in the future. Normal intent starts immediately when it is passed to startActivity(Intent)
or StartService(Intent)
.

- 237,138
- 77
- 654
- 440

- 321
- 3
- 2
What is an Intent?
An Intent is a specific command in Android that allows you to send a command to the Android OS to do something specific. Think of it as an action that needs to take place. There are many actions that can be done such as sending an email, or attaching a photo to an email, or even launching an application. The logical workflow of creating an intent is usually as follows: a. Create the Intent b. Add Intent options -> Ex. what type of intent we are sending to the OS or any attributes associated with that intent, such as a text string or something being passed along with the intent c. RUN the Intent
Real-Life Example: Let's say I wake up in the morning and I "INTEND" to go to the washroom. I will first have to THINK about going to the washroom, but that DOESN'T really gets me to the washroom. I will then have to tell my brain to get out of bed first, then walk to the washroom, and then release, then go and wash my hands, then go and wipe my hands. Once I know where I'm going I SEND the command to begin and my body takes action.
What is Pending Intents?
Continuing from the real-life example, let's say I want to take a shower but I want to shower AFTER I brush my teeth and eat breakfast. So I know I won't be showering until at least 30-40 minutes. I still have in my head that I need to prepare my clothes, and then walk up the stairs back to the bathroom, then undress and then shower. However, this will not happen until 30-40 minutes have passed. I now have a PENDING intent to shower. It is PENDING for 30-40 minutes.
That is pretty much the difference between a Pending Intent and a Regular Intent. Regular Intents can be created without a Pending Intent, however, in order to create a Pending Intent you need to have a Regular Intent setup first.

- 6,709
- 5
- 44
- 51

- 1,085
- 10
- 20
-
I really liked the simple and the example, I understood it pretty well with that words. – Josema Apr 25 '16 at 16:57
-
-
this is exactly the same as Shakeeb Ayaz's explanation above. who copied from whom? :) – likejudo Nov 16 '18 at 19:23
-
TAXI ANALOGY
Intent
Intents are typically used for starting Services. For example:
Intent intent = new Intent(CurrentClass.this, ServiceClass.class);
startService(intent);
This is like when you call for a taxi:
Myself = CurrentClass
Taxi Driver = ServiceClass
Pending Intent
You will need to use something like this:
Intent intent = new Intent(CurrentClass.this, ServiceClass.class);
PendingIntent pi = PendingIntent.getService(parameter, parameter, intent, parameter);
getDataFromThirdParty(parameter, parameter, pi, parameter);
Now this Third party will start the service acting on your behalf. A real life analogy is Uber or Lyft who are both taxi companies.
You send a request for a ride to Uber/Lyft. They will then go ahead and call one of their drivers on your behalf.
Therefore:
Uber/Lyft ------ ThirdParty which receives PendingIntent
Myself --------- Class calling PendingIntent
Taxi Driver ---- ServiceClass

- 12,245
- 6
- 43
- 74

- 3,734
- 3
- 26
- 29
-
Thanks for `new Intent(CurrentClass.this`. Everyone else just put `context` but you gave actual *context* on what to provide here. – LinusGeffarth Feb 20 '21 at 14:31
-
If you believe in God, God bless you, i feel like cryong right now, actual tears in my eyes. – Ezekiel Oct 27 '21 at 12:14
-
A future intent that other apps can use.
And here's an example for creating one:
Intent intent = new Intent(context, MainActivity.class);
PendingIntent pendIntent = PendingIntent.getActivity(context, 0, intent, 0);

- 28,523
- 10
- 105
- 71
-
9Downvote because you don't really explain what is special about an intent which is "future" or usable by other apps – Vic Feb 23 '14 at 20:11
-
@WhereDatApp.com it was said by Antoine de Saint Exupéry and translated by Lewis Galantière ;) – Choletski Jul 20 '16 at 15:48
-
A PendingIntent is a token that you give to another application (e.g. Notification Manager, Alarm Manager or other 3rd party applications), which allows this other application to use the permissions of your application to execute a predefined piece of code. To perform a broadcast via a pending intent so get a PendingIntent via PendingIntent.getBroadcast(). To perform an activity via an pending intent you receive the activity via PendingIntent.getActivity().

- 111
- 1
- 2
PendingIntent
is basically an object that wraps another Intent
object. Then it can be passed to a foreign application where you’re granting that app the right to perform the operation, i.e., execute the intent as if it were executed from your own app’s process (same permission and identity). For security reasons you should always pass explicit intents to a PendingIntent rather than being implicit.
PendingIntent aPendingIntent = PendingIntent.getService(Context, 0, aIntent,
PendingIntent.FLAG_CANCEL_CURRENT);

- 3,358
- 2
- 19
- 31
A PendingIntent wraps the general Intent with a token that you give to foreign app to execute with your permission. For eg:
The notification of your music app can't play/pause the music if you didn't give the
PendingIntent
to send broadcast because your music app hasREAD_EXTERNAL_STORAGE
permission which the notification app doesn't. Notification is a system service (so it's a foreign app).

- 3,363
- 5
- 29
- 35
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.
It is a token that you give to a foreign application which allows the foreign application to use your application’s permissions to execute a predefined piece of code.
If you give the foreign application an Intent, and that application sends/broadcasts the Intent you gave, they will execute the Intent with their own permissions. But if you instead give the foreign application a Pending Intent you created using your own permission, that application will execute the contained Intent using your application’s permission.
To perform a broadcast via a pending intent so get a PendingIntent via PendingIntent.getBroadcast(). To perform an activity via an pending intent you receive the activity via PendingIntent.getActivity().
It is an Intent action that you want to perform, but at a later time. Think of it a putting an Intent on ice. The reason it’s needed is because an Intent must be created and launched from a valid Context in your application, but there are certain cases where one is not available at the time you want to run the action because you are technically outside the application’s context (the two common examples are launching an Activity from a Notification or a BroadcastReceiver.
By creating a PendingIntent you want to use to launch, say, an Activity while you have the Context to do so (from inside another Activity or Service) you can pass that object around to something external in order for it to launch part of your application on your behalf.
A PendingIntent provides a means for applications to work, even after their process exits. Its important to note that even after the application that created the PendingIntent has been killed, that Intent can still run. A description of an Intent and target action to perform with it. Instances of this class are created with getActivity(Context, int, Intent, int), getBroadcast(Context, int, Intent, int), getService (Context, int, Intent, int); the returned object can be handed to other applications so that they can perform the action you described on your behalf at a later time.
By giving a PendingIntent to another application, you are granting it the right to perform the operation you have specified as if the other application was yourself (with the same permissions and identity). As such, you should be careful about how you build the PendingIntent: often, for example, the base Intent you supply will have the component name explicitly set to one of your own components, to ensure it is ultimately sent there and nowhere else.
A PendingIntent itself is simply a reference to a token maintained by the system describing the original data used to retrieve it. This means that, even if its owning application’s process is killed, the PendingIntent itself will remain usable from other processes that have been given it. If the creating application later re-retrieves the same kind of PendingIntent (same operation, same Intent action, data, categories, and components, and same flags), it will receive a PendingIntent representing the same token if that is still valid, and can thus call cancel() to remove it.

- 458
- 6
- 8
In an easy language,
1. A description of an Intent and Target action to perform. First you have to create an intent and then you have to pass an specific java class which you want to execute, to the Intent.
2. You can call those java class which is your class action class by PendingIntent.getActivity, PendingIntent.getActivities(Context, int, Intent[], int), PendingIntent.getBroadcast(Context, int, Intent, int), and PendingIntent.getService(Context, int, Intent, int);
Here you see that Intent which is comes from the step 1
3. You should keep in mind that...By giving a PendingIntent to another application, you are granting it the right to perform the operation you have specified.
That is what I learned after a long reading.

- 11,049
- 13
- 50
- 76

- 2,531
- 1
- 29
- 42
In simple terms
A pending intent
is basically an intent that you can pass to other apps or services like notification manager
, alarm manager
etc. and let them handle when is the right timing/behaviour for it to be executed.

- 904
- 6
- 33
As its name suggest .. PendingIntent
you can pend(do it after some time) it . It work as the other intent ..it is a way of giving your task to some other app to perform on your behalf.

- 33,936
- 20
- 234
- 300
Pending Intent
A pending intent is a wrapper around regular intent that is designed to be used by another application.
It gives that other application the ability to perform the included action as it was your application with all the permissions your application has been granted
When you want to open some application components like Activity/Service/BroadcastReceiver at later time or after some specified time interval you have to send PendingIntent in this case. It acts like a permission slip you gave to another apps to run your application’s code on your behalf after some time. So PendingIntent works beyond process boundaries like you want AlarmManager which is an another app in another process then AlarmManager perfom action on your app specified by PendingIntent

- 6,709
- 5
- 44
- 51
I have came across PendingIntents in Notifications. So here is a simple explanation:
We want to provide an Intent to Notification, in this case we want to open a Activity which performs Camera capture functionality. Here, if we pass simply Intent, the NotificationManager doesnt have this permission although my app has this permission stated in Manifest; due to this the action wont work as NotificationManager doesnt have the permission to do so.
But, if you use PendingIntent, here the permission that my app have will be used instead of NotificationManager. Therefore, even if NotificationManager doesnt have Camera permission and my app has it will still open up the activity and perform the app.
NOTE: Pending intent requires regular Intent to be setup first.

- 2,534
- 2
- 13
- 20