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 not happen. The
parts of the Intent that are used for matching are the same ones defined
by Intent.filterEquals. If you use two
Intent objects that are equivalent as per
Intent.filterEquals, then you will get
the same PendingIntent for both of them.

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.

Flag for use with writeToParcel(Parcel, int): the object being written
is a return value, that is the result of a function such as
"Parcelable someFunction()",
"void someFunction(out Parcelable)", or
"void someFunction(inout Parcelable)".

Causes the current thread to wait until another thread invokes the
notify() method or the
notifyAll() method for this object, or
some other thread interrupts the current thread, or a certain
amount of real time has elapsed.

You can use
this to retrieve a new PendingIntent when you are only changing the
extra data in the Intent; by canceling the previous pending intent,
this ensures that only entities given the new data will be able to
launch it. If this assurance is not an issue, consider
FLAG_UPDATE_CURRENT.

Constant Value:
268435456
(0x10000000)

FLAG_IMMUTABLE

Flag indicating that the created PendingIntent should be immutable.
This means that the additional intent argument passed to the send
methods to fill in unpopulated properties of this intent will be
ignored.

This can be used if you are creating intents where only the
extras change, and don't care that any entities that received your
previous PendingIntent will be able to launch it with your new
extras even if they are not explicitly given to it.

describeContents

Describe the kinds of special objects contained in this Parcelable
instance's marshaled representation. For example, if the object will
include a file descriptor in the output of writeToParcel(Parcel, int),
the return value of this method must include the
CONTENTS_FILE_DESCRIPTOR bit.

Returns

int

a bitmask indicating the set of special object types marshaled
by this Parcelable object instance.

The first intent in the array will be started outside of the context of an
existing activity, so you must use the Intent.FLAG_ACTIVITY_NEW_TASK launch flag in the Intent. (Activities after
the first in the array are started in the context of the previous activity
in the array, so FLAG_ACTIVITY_NEW_TASK is not needed nor desired for them.)

The last intent in the array represents the key for the
PendingIntent. In other words, it is the significant element for matching
(as done with the single intent given to getActivity(Context, int, Intent, int),
its content will be the subject of replacement by
send(Context, int, Intent) and FLAG_UPDATE_CURRENT, etc.
This is because it is the most specific of the supplied intents, and the
UI the user actually sees when the intents are started.

For security reasons, the Intent objects
you supply here should almost always be explicit intents,
that is specify an explicit component to be delivered to through
Intent.setClass

Parameters

context

Context: The Context in which this PendingIntent should start
the activity.

The first intent in the array will be started outside of the context of an
existing activity, so you must use the Intent.FLAG_ACTIVITY_NEW_TASK launch flag in the Intent. (Activities after
the first in the array are started in the context of the previous activity
in the array, so FLAG_ACTIVITY_NEW_TASK is not needed nor desired for them.)

The last intent in the array represents the key for the
PendingIntent. In other words, it is the significant element for matching
(as done with the single intent given to getActivity(Context, int, Intent, int),
its content will be the subject of replacement by
send(Context, int, Intent) and FLAG_UPDATE_CURRENT, etc.
This is because it is the most specific of the supplied intents, and the
UI the user actually sees when the intents are started.

For security reasons, the Intent objects
you supply here should almost always be explicit intents,
that is specify an explicit component to be delivered to through
Intent.setClass

Parameters

context

Context: The Context in which this PendingIntent should start
the activity.

getCreatorPackage

Return the package name of the application that created this
PendingIntent, that is the identity under which you will actually be
sending the Intent. The returned string is supplied by the system, so
that an application can not spoof its package.

Be careful about how you use this. All this tells you is
who created the PendingIntent. It does not tell you who
handed the PendingIntent to you: that is, PendingIntent objects are intended to be
passed between applications, so the PendingIntent you receive from an application
could actually be one it received from another application, meaning the result
you get here will identify the original application. Because of this, you should
only use this information to identify who you expect to be interacting with
through a send() call, not who gave you the PendingIntent.

getCreatorUid

Return the uid of the application that created this
PendingIntent, that is the identity under which you will actually be
sending the Intent. The returned integer is supplied by the system, so
that an application can not spoof its uid.

Be careful about how you use this. All this tells you is
who created the PendingIntent. It does not tell you who
handed the PendingIntent to you: that is, PendingIntent objects are intended to be
passed between applications, so the PendingIntent you receive from an application
could actually be one it received from another application, meaning the result
you get here will identify the original application. Because of this, you should
only use this information to identify who you expect to be interacting with
through a send() call, not who gave you the PendingIntent.

Returns

int

The uid of the PendingIntent, or -1 if there is
none associated with it.

getCreatorUserHandle

Return the user handle of the application that created this
PendingIntent, that is the user under which you will actually be
sending the Intent. The returned UserHandle is supplied by the system, so
that an application can not spoof its user. See
Process.myUserHandle() for
more explanation of user handles.

Be careful about how you use this. All this tells you is
who created the PendingIntent. It does not tell you who
handed the PendingIntent to you: that is, PendingIntent objects are intended to be
passed between applications, so the PendingIntent you receive from an application
could actually be one it received from another application, meaning the result
you get here will identify the original application. Because of this, you should
only use this information to identify who you expect to be interacting with
through a send() call, not who gave you the PendingIntent.

getTargetPackage

hashCode

Returns a hash code value for the object. This method is
supported for the benefit of hash tables such as those provided by
HashMap.

The general contract of hashCode is:

Whenever it is invoked on the same object more than once during
an execution of a Java application, the hashCode method
must consistently return the same integer, provided no information
used in equals comparisons on the object is modified.
This integer need not remain consistent from one execution of an
application to another execution of the same application.

If two objects are equal according to the equals(Object)
method, then calling the hashCode method on each of
the two objects must produce the same integer result.

It is not required that if two objects are unequal
according to the equals(java.lang.Object)
method, then calling the hashCode method on each of the
two objects must produce distinct integer results. However, the
programmer should be aware that producing distinct integer results
for unequal objects may improve the performance of hash tables.

As much as is reasonably practical, the hashCode method defined by
class Object does return distinct integers for distinct
objects. (This is typically implemented by converting the internal
address of the object into an integer, but this implementation
technique is not required by the
Java™ programming language.)

Context: The Context of the caller. This may be null if
intent is also null.

code

int: Result code to supply back to the PendingIntent's target.

intent

Intent: Additional Intent data. See Intent.fillIn() for information on how this is applied to the
original Intent. Use null to not modify the original Intent.
If flag FLAG_IMMUTABLE was set when this pending intent was
created, this argument will be ignored.

onFinished

PendingIntent.OnFinished: The object to call back on when the send has
completed, or null for no callback.

handler

Handler: Handler identifying the thread on which the callback
should happen. If null, the callback will happen from the thread
pool of the process.

requiredPermission

String: Name of permission that a recipient of the PendingIntent
is required to hold. This is only valid for broadcast intents, and
corresponds to the permission argument in
Context.sendOrderedBroadcast(Intent, String).
If null, no permission is required.

options

Bundle: Additional options the caller would like to provide to modify the sending
behavior. May be built from an ActivityOptions to apply to an activity start.

Context: The Context of the caller. This may be null if
intent is also null.

code

int: Result code to supply back to the PendingIntent's target.

intent

Intent: Additional Intent data. See Intent.fillIn() for information on how this is applied to the
original Intent. Use null to not modify the original Intent.
If flag FLAG_IMMUTABLE was set when this pending intent was
created, this argument will be ignored.

onFinished

PendingIntent.OnFinished: The object to call back on when the send has
completed, or null for no callback.

handler

Handler: Handler identifying the thread on which the callback
should happen. If null, the callback will happen from the thread
pool of the process.

Context: The Context of the caller. This may be null if
intent is also null.

code

int: Result code to supply back to the PendingIntent's target.

intent

Intent: Additional Intent data. See Intent.fillIn() for information on how this is applied to the
original Intent. Use null to not modify the original Intent.
If flag FLAG_IMMUTABLE was set when this pending intent was
created, this argument will be ignored.

onFinished

PendingIntent.OnFinished: The object to call back on when the send has
completed, or null for no callback.

handler

Handler: Handler identifying the thread on which the callback
should happen. If null, the callback will happen from the thread
pool of the process.

requiredPermission

String: Name of permission that a recipient of the PendingIntent
is required to hold. This is only valid for broadcast intents, and
corresponds to the permission argument in
Context.sendOrderedBroadcast(Intent, String).
If null, no permission is required.

send

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

Parameters

context

Context: The Context of the caller.

code

int: Result code to supply back to the PendingIntent's target.

intent

Intent: Additional Intent data. See Intent.fillIn() for information on how this is applied to the
original Intent. If flag FLAG_IMMUTABLE was set when this
pending intent was created, this argument will be ignored.

toString

Returns a string representation of the object. In general, the
toString method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.

The toString method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of: