Reputation: 13
I have some trouble with understanding of singleTop concept with launching Activities.
we have some activities A,B,C,D and singleTop is defined with activity B in manifest file.
As i read if we will go A->B->C->D->D than instance of D activity will not create and D will be top on the stack.
But if we will go A->B->C->D->B than what will happen? Which activity will be launch and which will be top on stack?
Please suggest.
Upvotes: 1
Views: 2196
Reputation: 561
The launch mode singleTop applies only for Activities that are on top of the stack.
Let the stack be A-B-C-D
(D on top) and D is an activity with singleTop launch mode. If you add another instance to this stack then D will not be instantiated again and the existing instance of D will receive a callback to onNewIntent()
.
Stack: A-B-C-D
But if the stack was like A-B-C-D-B
(B on top) and then you launch an activity of D, then it will simply create a new instance of D and put at the top of the stack. This is because D was not at the top of the stack.
Stack: A-B-C-D-B-D
Upvotes: 1