/** * Comparison operator on two PendingIntent objects, such that true is returned then they both * represent the same operation from the same package. This allows you to use {@link * #getActivity}, {@link #getBroadcast}, or {@link #getService} multiple times (even across a * process being killed), resulting in different PendingIntent objects but whose equals() method * identifies them as being the same operation. */ @Override public boolean equals(Object otherObj) { if (otherObj instanceof PendingIntent) { return mTarget.asBinder().equals(((PendingIntent) otherObj).mTarget.asBinder()); } return false; }
/** * Perform the operation associated with this PendingIntent, allowing the caller to specify * information about the Intent to use and be notified when the send has completed. * * <p>For the intent parameter, a PendingIntent often has restrictions on which fields can be * supplied here, based on how the PendingIntent was retrieved in {@link #getActivity}, {@link * #getBroadcast}, or {@link #getService}. * * @param context The Context of the caller. This may be null if <var>intent</var> is also null. * @param code Result code to supply back to the PendingIntent's target. * @param intent Additional Intent data. See {@link Intent#fillIn Intent.fillIn()} for information * on how this is applied to the original Intent. Use null to not modify the original Intent. * If flag {@link #FLAG_IMMUTABLE} was set when this pending intent was created, this argument * will be ignored. * @param onFinished The object to call back on when the send has completed, or null for no * callback. * @param handler Handler identifying the thread on which the callback should happen. If null, the * callback will happen from the thread pool of the process. * @param 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 {@link Context#sendBroadcast(Intent, String) * Context.sendOrderedBroadcast(Intent, String)}. If null, no permission is required. * @param options Additional options the caller would like to provide to modify the sending * behavior. May be built from an {@link ActivityOptions} to apply to an activity start. * @see #send() * @see #send(int) * @see #send(Context, int, Intent) * @see #send(int, android.app.PendingIntent.OnFinished, Handler) * @see #send(Context, int, Intent, OnFinished, Handler) * @throws CanceledException Throws CanceledException if the PendingIntent is no longer allowing * more intents to be sent through it. */ public void send( Context context, int code, @Nullable Intent intent, @Nullable OnFinished onFinished, @Nullable Handler handler, @Nullable String requiredPermission, @Nullable Bundle options) throws CanceledException { 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, options); if (res < 0) { throw new CanceledException(); } } catch (RemoteException e) { throw new CanceledException(e); } }
@Override public String toString() { StringBuilder sb = new StringBuilder(128); sb.append("PendingIntent{"); sb.append(Integer.toHexString(System.identityHashCode(this))); sb.append(": "); sb.append(mTarget != null ? mTarget.asBinder() : null); sb.append('}'); return sb.toString(); }
public void writeToParcel(Parcel out, int flags) { out.writeStrongBinder(mTarget.asBinder()); }
@Override public int hashCode() { return mTarget.asBinder().hashCode(); }