Reputation: 3759
I want start multiple app at the same time
so I use this
startActivity(getPackageManager().getLaunchIntentForPackage("com.android.chrome"));
startActivity(getPackageManager().getLaunchIntentForPackage("com.android.settings"));
I tried many packages, the default android app or the app from google play
only the last app can be started. How to modify the program to start multiple intent?
Upvotes: 0
Views: 1531
Reputation: 276
Please, check startActivities() method.
As following documentation snippet states:
Note that unlike that approach, generally none of the activities except the last in the array will be created at this point, but rather will be created when the user first visits them (due to pressing back from the activity on top).
That is, multiple apps can be started via intents but each next Activity overlays the previous one.
Update
Try following code:
public void launchActivities(View v) {
AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
Intent startChrome = getPackageManager().getLaunchIntentForPackage("com.android.chrome");
PendingIntent pi1 = PendingIntent.getActivity(getApplicationContext(), 666, startChrome, 0);
alarmManager.set(AlarmManager.RTC, System.currentTimeMillis() + 500, pi1);
Intent startSettings = getPackageManager().getLaunchIntentForPackage("com.android.settings");
PendingIntent pi2 = PendingIntent.getActivity(getApplicationContext(), 667, startSettings, 0);
alarmManager.set(AlarmManager.RTC, System.currentTimeMillis() + 1000, pi2);
finish();
}
Change System.currentTimeMillis() + N
parameter to set the appropriate time between launches.
Upvotes: 1