In the official online Android guide on tasks and back stack, there's a piece of information i find self-contradicting. So i'd be grateful if somebody could help me figure it out.
First off, there's the following statement:
Activities in the stack are never rearranged, only pushed and popped from the stack—pushed onto the stack when started by the current activity and popped off when the user leaves it using the Back button.
And then the singleTask launch mode is described, there's the following statement:
The system creates a new task and instantiates the activity at the root of the new task. However, if an instance of the activity already exists in a separate task, the system routes the intent to the existing instance through a call to its onNewIntent() method, rather than creating a new instance.
Well, if i understand this correctly, the singleTask activities can only be the roots of their tasks, since they are created that way and the activities never trade places in the back stack. But how would such an activity react on receiving that call to its onNewIntent() method?
There's another remark about this matter on that page:
As another example, the Android Browser application declares that the web browser activity should always open in its own task—by specifying the singleTask launch mode in the element. This means that if your application issues an intent to open the Android Browser, its activity is not placed in the same task as your application. Instead, either a new task starts for the Browser or, if the Browser already has a task running in the background, that task is brought forward to handle the new intent.
So, the guide states that invoking a singleTask activity somehow brings it forward. But how can it be true if that activity is not on top of its task? Is the activity resumed, or it simply receives a call to its onNewIntent() method without being displayed to the user? I really don't understand.
PS: An almost identical question had already been asked more than a year ago, but there was no proper answer given to it. So while technically my question is a duplicate, i feel an urge to re-ask it since it really deserves a clear and unambiguous answer.