I have doubt with android backstack , please consider the scenario I have two activities A and B in same app ,
- start with A.
- from A launch B using
FLAG_ACTIVITY_NEW_TASK - from B launch A using
FLAG_ACTIVITY_NEW_TASK - press Back button 3 times to return to home screen.
My question is how does the backstack work with this flag , is new task created every time and previous task is pushed to background or activity is created on top of same task.
My doubt is if first one is correct then does back button really remove the activity from top of the stack and if second is correct what is the use of that flag in correct sense.
Thanks in advance.
Regards,
Rohit
First of all, launching B using
FLAG_ACTIVITY_NEW_TASKwill NOT create a new task unless you have explicitly setandroid:taskAffinityin the manifest for B. The reason for this is that, by default, all Activities in your application have the sametaskAffinityandtaskAffinityoverridesFLAG_ACTIVITY_NEW_TASK.If you have set the taskAffinity of A and/or B so that they are different (or both empty), then it works like this: