I a bit confused with the documentation for launch modes. Specifically the doc mentions:
Activities in the stack are never rearranged, only pushed and popped from the stack
But later in the section for FLAG_ACTIVITY_NEW_TASK it is mentioned:
If a task is already running for the activity you are now starting, that task is brought to the foreground with its last state restored and the activity receives the new intent in onNewIntent().
There is no clarification here if that the activity is on the top of the stack and this makes me wonder how is that possible without rearranging the stack.
So for instance if we have activities A and B and A launches B:
A<-B
Now if B launches A with FLAG_ACTIVITY_NEW_TASK would that mean that it would resume the previous instance? I.e. the back stack will be:
B <- A
or would we have:
A <- B <- A
all the destination added to the backstack will be popped till the one that you're requesting to. So in your case the result should be only activity A with the
onNewIntent()method call. Refer to this article with examples about task and backstack