Click here to Skip to main content
15,885,855 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Looks like Every tutorial that we have got out there on the Web mentions that FLAG_ACTIVITY_NEW_TASK Starts a new task if the Activity we are starting is not currently running in the task.But it seems that using FLAG_ACTIVITY_NEW_TASK doesn't Creates a New Task Always, it is only Creating a new task if there is no task available for the activity we need to run like when we start an activity from a BroadCastReceiver using the context inside onReceive().

According to the all the tutorials on the web,

Suppose We have got following activities in our BackStack-

Java
A->B->C

Now If We want to start a new Activity D, then it should start in a New Task, but this doesn't seems to happens and the activity D is Started in the Same task and we have out final backstack

A->B->C->D
AnyOne Who Can Clarify?

What I have tried:

I know Setting Affinity will result in new task but this brings another problem:

Try Yourself:

Suppose we launch two Activity:

A-B
Then again we launch one other Activity with android:taskAffinity**,So now we have got**

Java
A-B | C
A-B (on the same task)
C (on other task)

Now Again We start A-B from C,So now our BackStack will Look like:
Java
A-B|C-A-B
A-B(on the same task)
C-A-B(on other task)



Now, the problem is If We will Again try to start C from B (from task C-A-B), nothing happens and C will not get launch (I din't know why?)
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900