PendingIntent Class

Definition

A description of an Intent and target action to perform with it.

[Android.Runtime.Register("android/app/PendingIntent", DoNotGenerateAcw=true)]
public sealed class PendingIntent : Java.Lang.Object, Android.OS.IParcelable, IDisposable, Java.Interop.IJavaPeerable
[<Android.Runtime.Register("android/app/PendingIntent", DoNotGenerateAcw=true)>]
type PendingIntent = class
    inherit Object
    interface IParcelable
    interface IJavaObject
    interface IDisposable
    interface IJavaPeerable
Inheritance
PendingIntent
Attributes
Implements

Remarks

A description of an Intent and target action to perform with it. Instances of this class are created with #getActivity, #getActivities, #getBroadcast, and #getService; 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: almost always, for example, the base Intent you supply should 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.

Because of this behavior, it is important to know when two Intents are considered to be the same for purposes of retrieving a PendingIntent. A common mistake people make is to create multiple PendingIntent objects with Intents that only vary in their "extra" contents, expecting to get a different PendingIntent each time. This does <em>not</em> happen. The parts of the Intent that are used for matching are the same ones defined by Intent#filterEquals(Intent) Intent.filterEquals. If you use two Intent objects that are equivalent as per Intent#filterEquals(Intent) Intent.filterEquals, then you will get the same PendingIntent for both of them.

There are two typical ways to deal with this.

If you truly need multiple distinct PendingIntent objects active at the same time (such as to use as two notifications that are both shown at the same time), then you will need to ensure there is something that is different about them to associate them with different PendingIntents. This may be any of the Intent attributes considered by Intent#filterEquals(Intent) Intent.filterEquals, or different request code integers supplied to #getActivity, #getActivities, #getBroadcast, or #getService.

If you only need one PendingIntent active at a time for any of the Intents you will use, then you can alternatively use the flags #FLAG_CANCEL_CURRENT or #FLAG_UPDATE_CURRENT to either cancel or modify whatever current PendingIntent is associated with the Intent you are supplying.

Also note that flags like #FLAG_ONE_SHOT or #FLAG_IMMUTABLE describe the PendingIntent instance and thus, are used to identify it. Any calls to retrieve or modify a PendingIntent created with these flags will also require these flags to be supplied in conjunction with others. E.g. To retrieve an existing PendingIntent created with FLAG_ONE_SHOT, <b>both</b> FLAG_ONE_SHOT and FLAG_NO_CREATE need to be supplied.

Java documentation for android.app.PendingIntent.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Fields

FlagAllowUnsafeImplicitIntent
Obsolete.

Flag indicating that the created PendingIntent with #FLAG_MUTABLE is allowed to have an unsafe implicit Intent within.

FlagMutable
Obsolete.

Flag indicating that the created PendingIntent should be mutable.

Properties

Class

Returns the runtime class of this Object.

(Inherited from Object)
Creator
CreatorPackage

Return the package name of the application that created this PendingIntent, that is the identity under which you will actually be sending the Intent.

CreatorUid

Return the uid of the application that created this PendingIntent, that is the identity under which you will actually be sending the Intent.

CreatorUserHandle

Return the user handle of the application that created this PendingIntent, that is the user under which you will actually be sending the Intent.

Handle

The handle to the underlying Android instance.

(Inherited from Object)
IntentSender

Retrieve a IntentSender object that wraps the existing sender of the PendingIntent

IsActivity
IsBroadcast
IsForegroundService
IsImmutable

Check if this PendingIntent is marked with #FLAG_IMMUTABLE.

IsService
JniIdentityHashCode (Inherited from Object)
JniPeerMembers
PeerReference (Inherited from Object)
TargetPackage
Obsolete.

This member is deprecated.

ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

(Inherited from Object)
ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

(Inherited from Object)

Methods

Cancel()

Cancel a currently active PendingIntent.

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
DescribeContents()

Describe the kinds of special objects contained in this Parcelable's marshalled representation.

Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
GetActivities(Context, Int32, Intent[], PendingIntentFlags)

Like #getActivity(Context, int, Intent, int), but allows an array of Intents to be supplied.

GetActivities(Context, Int32, Intent[], PendingIntentFlags, Bundle)

Like #getActivity(Context, int, Intent, int), but allows an array of Intents to be supplied.

GetActivity(Context, Int32, Intent, PendingIntentFlags)

Retrieve a PendingIntent that will start a new activity, like calling Context#startActivity(Intent) Context.startActivity(Intent).

GetActivity(Context, Int32, Intent, PendingIntentFlags, Bundle)

Retrieve a PendingIntent that will start a new activity, like calling Context#startActivity(Intent) Context.startActivity(Intent).

GetBroadcast(Context, Int32, Intent, PendingIntentFlags)

Retrieve a PendingIntent that will perform a broadcast, like calling Context#sendBroadcast(Intent) Context.sendBroadcast().

GetForegroundService(Context, Int32, Intent, PendingIntentFlags)

Retrieve a PendingIntent that will start a foreground service, like calling Context#startForegroundService Context.startForegroundService().

GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
GetService(Context, Int32, Intent, PendingIntentFlags)

Retrieve a PendingIntent that will start a service, like calling Context#startService Context.startService().

JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
ReadPendingIntentOrNullFromParcel(Parcel)

Convenience function for reading either a PendingIntent or null pointer from a Parcel.

Send()

Perform the operation associated with this PendingIntent.

Send(Bundle)

Perform the operation associated with this PendingIntent, supplying additional options for the operation.

Send(Context, Result, Intent)

Perform the operation associated with this PendingIntent, allowing the caller to specify information about the Intent to use.

Send(Context, Result, Intent, PendingIntent+IOnFinished, Handler)

Perform the operation associated with this PendingIntent.

Send(Context, Result, Intent, PendingIntent+IOnFinished, Handler, String)

Perform the operation associated with this PendingIntent.

Send(Context, Result, Intent, PendingIntent+IOnFinished, Handler, String, Bundle)

Perform the operation associated with this PendingIntent.

Send(Result)

Perform the operation associated with this PendingIntent.

Send(Result, PendingIntent+IOnFinished, Handler)

Perform the operation associated with this PendingIntent.

SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
ToArray<T>() (Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
UnregisterFromRuntime() (Inherited from Object)
Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
WritePendingIntentOrNullToParcel(PendingIntent, Parcel)

Convenience function for writing either a PendingIntent or null pointer to a Parcel.

WriteToParcel(Parcel, ParcelableWriteFlags)

Flatten this object in to a Parcel.

Explicit Interface Implementations

IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Applies to