Issue
I am trying out the demo provided by https://developer.android.com/training/basics/activity-lifecycle/index.html.
I can see when I start B or C, a new activity B or C will be created, and if I Finish B or C it will be only one step backward, just like: creating A->B->C->B->C, then by finish C then B then C then B I will get to A.
Although if I try to start A in the process, it will go to the original first A, just like: creating A->B->C, then I create A, it just become A(instead of A->B->C->A).
The code for activity A, B and C look the same to me, is it because A is the main activity? do I miss something?
Solution
It's because the launchMode
for Activity A is "singleTask". This gets declared in the AndroidManifest.xml file under Activity A's <activity>
tag. From this file, you can modify many aspects of the the behavior of your Activities, Services, etc. From the documentation:
In contrast, "singleTask" and "singleInstance" activities can only begin a task. They are always at the root of the activity stack. Moreover, the device can hold only one instance of the activity at a time — only one such task.
Answered By - MattDavis
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.