tags:

views:

104

answers:

1

I want to create multiple instances of an activity in the same process. Should I use FLAG_ACTIVITY_NEW_TASK flag like the code below?

                Intent i = new Intent();
                i.setClass(this, A.class);
                i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
                startActivity(i);

This code is executed in class A to create another instance of activity A.

This question, will this code create another task? As I understand is a process can only have one task. Does it mean the two activities will exist in different tasks? That's what I want. I want the two activities to be in the same process.

Thanks.

A: 

Just start the activity, with no special flags. Activities create multiple instances by default. In fact, you have to do some work to prevent getting multiple instances when you don't want them.

CommonsWare