IntentSenderpublic class IntentSender extends Object implements android.os.ParcelableA description of an Intent and target action to perform with it.
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 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 {@link android.app.PendingIntent} with
{@link android.app.PendingIntent#getIntentSender() PendingIntent.getIntentSender()}. |
Fields Summary |
---|
private final android.content.IIntentSender | mTarget | public static final Parcelable.Creator | CREATOR |
Methods Summary |
---|
public int | describeContents()
return 0;
| public boolean | equals(java.lang.Object otherObj)Comparison operator on two IntentSender objects, such that true
is returned then they both represent the same operation from the
same package.
if (otherObj instanceof IntentSender) {
return mTarget.asBinder().equals(((IntentSender)otherObj)
.mTarget.asBinder());
}
return false;
| public java.lang.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. The returned string is supplied by the system, so
that an application can not spoof its package.
try {
return ActivityManagerNative.getDefault()
.getPackageForIntentSender(mTarget);
} catch (RemoteException e) {
// Should never happen.
return null;
}
| public 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. The returned integer is supplied by the system, so
that an application can not spoof its uid.
try {
return ActivityManagerNative.getDefault()
.getUidForIntentSender(mTarget);
} catch (RemoteException e) {
// Should never happen.
return -1;
}
| public android.os.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. The returned UserHandle is supplied by the system, so
that an application can not spoof its user. See
{@link android.os.Process#myUserHandle() Process.myUserHandle()} for
more explanation of user handles.
try {
int uid = ActivityManagerNative.getDefault()
.getUidForIntentSender(mTarget);
return uid > 0 ? new UserHandle(UserHandle.getUserId(uid)) : null;
} catch (RemoteException e) {
// Should never happen.
return null;
}
| public android.content.IIntentSender | getTarget()
return mTarget;
| public java.lang.String | getTargetPackage()
try {
return ActivityManagerNative.getDefault()
.getPackageForIntentSender(mTarget);
} catch (RemoteException e) {
// Should never happen.
return null;
}
| public int | hashCode()
return mTarget.asBinder().hashCode();
| public static android.content.IntentSender | readIntentSenderOrNullFromParcel(android.os.Parcel in)Convenience function for reading either a Messenger or null pointer from
a Parcel. You must have previously written the Messenger with
{@link #writeIntentSenderOrNullToParcel}.
IBinder b = in.readStrongBinder();
return b != null ? new IntentSender(b) : null;
| public void | sendIntent(android.content.Context context, int code, android.content.Intent intent, android.content.IntentSender$OnFinished onFinished, android.os.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.
sendIntent(context, code, intent, onFinished, handler, null);
| public void | sendIntent(android.content.Context context, int code, android.content.Intent intent, android.content.IntentSender$OnFinished onFinished, android.os.Handler handler, java.lang.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.
try {
String resolvedType = intent != null ?
intent.resolveTypeIfNeeded(context.getContentResolver())
: null;
int res = mTarget.send(code, intent, resolvedType,
onFinished != null
? new FinishedDispatcher(this, onFinished, handler)
: null,
requiredPermission);
if (res < 0) {
throw new SendIntentException();
}
} catch (RemoteException e) {
throw new SendIntentException();
}
| public java.lang.String | toString()
StringBuilder sb = new StringBuilder(128);
sb.append("IntentSender{");
sb.append(Integer.toHexString(System.identityHashCode(this)));
sb.append(": ");
sb.append(mTarget != null ? mTarget.asBinder() : null);
sb.append('}");
return sb.toString();
| public static void | writeIntentSenderOrNullToParcel(android.content.IntentSender sender, android.os.Parcel out)Convenience function for writing either a IntentSender or null pointer to
a Parcel. You must use this with {@link #readIntentSenderOrNullFromParcel}
for later reading it.
out.writeStrongBinder(sender != null ? sender.mTarget.asBinder()
: null);
| public void | writeToParcel(android.os.Parcel out, int flags)
out.writeStrongBinder(mTarget.asBinder());
|
|