Android - start multiple activities

Waypoint picture Waypoint · Oct 7, 2011 · Viewed 27.3k times · Source

is it possible to start multiple activities at once? I mean, from main create 3 activities in some order and just the last will be visible? Up to now, I was able to create only one activity.

Thanks

Answer

Raginmari picture Raginmari · May 30, 2012

You might need something like this in order to launch deep into the app after the user has clicked a notification in order to display some newly added content, for example.

Intent i = new Intent(this, A.class);
i.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivity(i);

Intent j = new Intent(this, B.class);
j.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivity(j);

Intent k = new Intent(this, C.class);
startActivity(k);

In this way you can start activities A, B and C at the same time and suppress transitions to activities A and B. You get a single transition from your current activity to activity C. I strongly suggest that you log the Activity lifecycle method calls (onCreate etc.) to LogCat, for example. It helps a lot in understanding the order of events.