We have answer of your question!

100% solved queries, no empty question

Question: Managing the Activity Lifecycle demo activity return to original A if Start A


0

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?

Question author Poiu2000 | Source

Answer


1


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.

Answer author Mattdavis

Tickanswer.com is providing the only single recommended solution of the question Managing the Activity Lifecycle demo activity return to original A if Start A under the categories i.e android , android-lifecycle , . Our team of experts filter the best solution for you.

Related Search Queries:


You may also add your answer

Thanks for contributing an answer to Tick Answer!