@@ -394,6 +394,31 @@ public static PendingIntent getActivities(Context context, int requestCode,
394394 return null ;
395395 }
396396
397+ /**
398+ * @hide
399+ * Note that UserHandle.CURRENT will be interpreted at the time the
400+ * activity is started, not when the pending intent is created.
401+ */
402+ public static PendingIntent getActivitiesAsUser (Context context , int requestCode ,
403+ Intent [] intents , int flags , Bundle options , UserHandle user ) {
404+ String packageName = context .getPackageName ();
405+ String [] resolvedTypes = new String [intents .length ];
406+ for (int i =0 ; i <intents .length ; i ++) {
407+ intents [i ].setAllowFds (false );
408+ resolvedTypes [i ] = intents [i ].resolveTypeIfNeeded (context .getContentResolver ());
409+ }
410+ try {
411+ IIntentSender target =
412+ ActivityManagerNative .getDefault ().getIntentSender (
413+ ActivityManager .INTENT_SENDER_ACTIVITY , packageName ,
414+ null , null , requestCode , intents , resolvedTypes ,
415+ flags , options , user .getIdentifier ());
416+ return target != null ? new PendingIntent (target ) : null ;
417+ } catch (RemoteException e ) {
418+ }
419+ return null ;
420+ }
421+
397422 /**
398423 * Retrieve a PendingIntent that will perform a broadcast, like calling
399424 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
0 commit comments