コード例 #1
0
 /**
  * @hide Note that UserHandle.CURRENT will be interpreted at the time the activity is started, not
  *     when the pending intent is created.
  */
 public static PendingIntent getActivitiesAsUser(
     Context context,
     int requestCode,
     @NonNull Intent[] intents,
     int flags,
     Bundle options,
     UserHandle user) {
   String packageName = context.getPackageName();
   String[] resolvedTypes = new String[intents.length];
   for (int i = 0; i < intents.length; i++) {
     intents[i].migrateExtraStreamToClipData();
     intents[i].prepareToLeaveProcess();
     resolvedTypes[i] = intents[i].resolveTypeIfNeeded(context.getContentResolver());
   }
   try {
     IIntentSender target =
         ActivityManagerNative.getDefault()
             .getIntentSender(
                 ActivityManager.INTENT_SENDER_ACTIVITY,
                 packageName,
                 null,
                 null,
                 requestCode,
                 intents,
                 resolvedTypes,
                 flags,
                 options,
                 user.getIdentifier());
     return target != null ? new PendingIntent(target) : null;
   } catch (RemoteException e) {
   }
   return null;
 }
コード例 #2
0
 /**
  * @hide Note that UserHandle.CURRENT will be interpreted at the time the broadcast is sent, not
  *     when the pending intent is created.
  */
 public static PendingIntent getBroadcastAsUser(
     Context context, int requestCode, Intent intent, int flags, UserHandle userHandle) {
   String packageName = context.getPackageName();
   String resolvedType =
       intent != null ? intent.resolveTypeIfNeeded(context.getContentResolver()) : null;
   try {
     intent.prepareToLeaveProcess();
     IIntentSender target =
         ActivityManagerNative.getDefault()
             .getIntentSender(
                 ActivityManager.INTENT_SENDER_BROADCAST,
                 packageName,
                 null,
                 null,
                 requestCode,
                 new Intent[] {intent},
                 resolvedType != null ? new String[] {resolvedType} : null,
                 flags,
                 null,
                 userHandle.getIdentifier());
     return target != null ? new PendingIntent(target) : null;
   } catch (RemoteException e) {
   }
   return null;
 }
コード例 #3
0
 /**
  * @hide Note that UserHandle.CURRENT will be interpreted at the time the activity is started, not
  *     when the pending intent is created.
  */
 public static PendingIntent getActivityAsUser(
     Context context,
     int requestCode,
     @NonNull Intent intent,
     int flags,
     Bundle options,
     UserHandle user) {
   String packageName = context.getPackageName();
   String resolvedType =
       intent != null ? intent.resolveTypeIfNeeded(context.getContentResolver()) : null;
   try {
     intent.migrateExtraStreamToClipData();
     intent.prepareToLeaveProcess();
     IIntentSender target =
         ActivityManagerNative.getDefault()
             .getIntentSender(
                 ActivityManager.INTENT_SENDER_ACTIVITY,
                 packageName,
                 null,
                 null,
                 requestCode,
                 new Intent[] {intent},
                 resolvedType != null ? new String[] {resolvedType} : null,
                 flags,
                 options,
                 user.getIdentifier());
     return target != null ? new PendingIntent(target) : null;
   } catch (RemoteException e) {
   }
   return null;
 }