Example usage for android.app PendingIntent PendingIntent

List of usage examples for android.app PendingIntent PendingIntent

Introduction

In this page you can find the example usage for android.app PendingIntent PendingIntent.

Prototype

PendingIntent(IIntentSender target) 

Source Link

Usage

From source file:android.app.Activity.java

/**
 * Create a new PendingIntent object which you can hand to others 
 * for them to use to send result data back to your 
 * {@link #onActivityResult} callback.  The created object will be either 
 * one-shot (becoming invalid after a result is sent back) or multiple 
 * (allowing any number of results to be sent through it). 
 *  //from  ww w. j  a v  a 2  s.  c  o m
 * @param requestCode Private request code for the sender that will be
 * associated with the result data when it is returned.  The sender can not
 * modify this value, allowing you to identify incoming results.
 * @param data Default data to supply in the result, which may be modified
 * by the sender.
 * @param flags May be {@link PendingIntent#FLAG_ONE_SHOT PendingIntent.FLAG_ONE_SHOT},
 * {@link PendingIntent#FLAG_NO_CREATE PendingIntent.FLAG_NO_CREATE},
 * {@link PendingIntent#FLAG_CANCEL_CURRENT PendingIntent.FLAG_CANCEL_CURRENT},
 * {@link PendingIntent#FLAG_UPDATE_CURRENT PendingIntent.FLAG_UPDATE_CURRENT},
 * or any of the flags as supported by
 * {@link Intent#fillIn Intent.fillIn()} to control which unspecified parts
 * of the intent that can be supplied when the actual send happens.
 * 
 * @return Returns an existing or new PendingIntent matching the given
 * parameters.  May return null only if
 * {@link PendingIntent#FLAG_NO_CREATE PendingIntent.FLAG_NO_CREATE} has been
 * supplied.
 * 
 * @see PendingIntent
 */
public PendingIntent createPendingResult(int requestCode, Intent data, int flags) {
    String packageName = getPackageName();
    try {
        data.prepareToLeaveProcess();
        IIntentSender target = ActivityManagerNative.getDefault().getIntentSender(
                ActivityManager.INTENT_SENDER_ACTIVITY_RESULT, packageName,
                mParent == null ? mToken : mParent.mToken, mEmbeddedID, requestCode, new Intent[] { data },
                null, flags, null, UserHandle.myUserId());
        return target != null ? new PendingIntent(target) : null;
    } catch (RemoteException e) {
        // Empty
    }
    return null;
}