public class IntentSender extends Object implements Parcelable
By giving a IntentSender 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 IntentSender: 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 IntentSender 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 IntentSender itself will remain usable from other processes that have been given it. If the creating application later re-retrieves the same kind of IntentSender (same operation, same Intent action, data, categories, and components, and same flags), it will receive a IntentSender representing the same token if that is still valid.
Instances of this class can not be made directly, but rather must be
created from an existing PendingIntent
with
PendingIntent.getIntentSender()
.
Modifier and Type | Class and Description |
---|---|
static interface |
IntentSender.OnFinished
Callback interface for discovering when a send operation has
completed.
|
static class |
IntentSender.SendIntentException
Exception thrown when trying to send through a PendingIntent that
has been canceled or is otherwise no longer able to execute the request.
|
Parcelable.ClassLoaderCreator<T>, Parcelable.Creator<T>
Modifier and Type | Field and Description |
---|---|
static Parcelable.Creator<IntentSender> |
CREATOR |
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_ELIDE_DUPLICATES, PARCELABLE_WRITE_RETURN_VALUE
Constructor and Description |
---|
IntentSender(IIntentSender target) |
Modifier and Type | Method and Description |
---|---|
int |
describeContents()
Describe the kinds of special objects contained in this Parcelable
instance's marshaled representation.
|
boolean |
equals(Object otherObj)
Comparison operator on two IntentSender objects, such that true
is returned then they both represent the same operation from the
same package.
|
String |
getCreatorPackage()
Return the package name of the application that created this
IntentSender, that is the identity under which you will actually be
sending the Intent.
|
int |
getCreatorUid()
Return the uid of the application that created this
PendingIntent, that is the identity under which you will actually be
sending the Intent.
|
UserHandle |
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.
|
IIntentSender |
getTarget() |
String |
getTargetPackage()
Deprecated.
Renamed to
getCreatorPackage() . |
int |
hashCode()
Returns a hash code value for the object.
|
static IntentSender |
readIntentSenderOrNullFromParcel(Parcel in)
Convenience function for reading either a Messenger or null pointer from
a Parcel.
|
void |
sendIntent(Context context,
int code,
Intent intent,
IntentSender.OnFinished onFinished,
Handler handler)
Perform the operation associated with this IntentSender, allowing the
caller to specify information about the Intent to use and be notified
when the send has completed.
|
void |
sendIntent(Context context,
int code,
Intent intent,
IntentSender.OnFinished onFinished,
Handler handler,
String requiredPermission)
Perform the operation associated with this IntentSender, allowing the
caller to specify information about the Intent to use and be notified
when the send has completed.
|
String |
toString()
Returns a string representation of the object.
|
static void |
writeIntentSenderOrNullToParcel(IntentSender sender,
Parcel out)
Convenience function for writing either a IntentSender or null pointer to
a Parcel.
|
void |
writeToParcel(Parcel out,
int flags)
Flatten this object in to a Parcel.
|
public static final Parcelable.Creator<IntentSender> CREATOR
public void sendIntent(Context context, int code, Intent intent, IntentSender.OnFinished onFinished, Handler handler) throws IntentSender.SendIntentException
context
- The Context of the caller. This may be null if
intent is also null.code
- Result code to supply back to the IntentSender's target.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.onFinished
- The object to call back on when the send has
completed, or null for no callback.handler
- Handler identifying the thread on which the callback
should happen. If null, the callback will happen from the thread
pool of the process.IntentSender.SendIntentException
- Throws CanceledIntentException if the IntentSender
is no longer allowing more intents to be sent through it.public void sendIntent(Context context, int code, Intent intent, IntentSender.OnFinished onFinished, Handler handler, String requiredPermission) throws IntentSender.SendIntentException
context
- The Context of the caller. This may be null if
intent is also null.code
- Result code to supply back to the IntentSender's target.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.onFinished
- The object to call back on when the send has
completed, or null for no callback.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
- 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.IntentSender.SendIntentException
- Throws CanceledIntentException if the IntentSender
is no longer allowing more intents to be sent through it.@Deprecated public String getTargetPackage()
getCreatorPackage()
.public String getCreatorPackage()
public int getCreatorUid()
public UserHandle getCreatorUserHandle()
Process.myUserHandle()
for
more explanation of user handles.public boolean equals(Object otherObj)
equals
in class Object
otherObj
- the reference object with which to compare.true
if this object is the same as the obj
argument; false
otherwise.Object.hashCode()
,
HashMap
public int hashCode()
Object
HashMap
.
The general contract of hashCode
is:
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.
equals(Object)
method, then calling the hashCode
method on each of
the two objects must produce the same integer result.
Object.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
JavaTM programming language.)
hashCode
in class Object
Object.equals(java.lang.Object)
,
System.identityHashCode(java.lang.Object)
public String toString()
Object
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:
getClass().getName() + '@' + Integer.toHexString(hashCode())
public int describeContents()
Parcelable
Parcelable.writeToParcel(Parcel, int)
,
the return value of this method must include the
Parcelable.CONTENTS_FILE_DESCRIPTOR
bit.describeContents
in interface Parcelable
Parcelable.CONTENTS_FILE_DESCRIPTOR
public void writeToParcel(Parcel out, int flags)
Parcelable
writeToParcel
in interface Parcelable
out
- The Parcel in which the object should be written.flags
- Additional flags about how the object should be written.
May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE
.public static void writeIntentSenderOrNullToParcel(IntentSender sender, Parcel out)
readIntentSenderOrNullFromParcel(android.os.Parcel)
for later reading it.sender
- The IntentSender to write, or null.out
- Where to write the IntentSender.public static IntentSender readIntentSenderOrNullFromParcel(Parcel in)
writeIntentSenderOrNullToParcel(android.content.IntentSender, android.os.Parcel)
.in
- The Parcel containing the written Messenger.public IIntentSender getTarget()