I tried using this code to start multiple Activities from a parent activity:
for (int i=0; i<NUM_ACTIVITIES; i++)
{
Intent intent = new Intent(this, MyActivity.class);
startActivity(intent);
}
However, according to my log in MyActivity.onCreate(), only 1 Activity was actually created. Is this behavior expected? If so, what’s the proper way to launch multiple Activities?
You can’t have multiple activities on top at the same time. Are you trying to have them run in order, one after the other?
One way to accomplish this is to start each activity for result:
Where you use the request code to track when activity is running. Then, in onActivityResult you can start the next one:
Edit:
If you want to have some of the activities immediatly in the background, you can chain them together by calling startActivity in each Activity’s onCreate. If you start a new Activity in onCreate before creating any views, the activity will never be visible.
This should accomplish the stack that you wanted..