管理活动生命周期的演示活动恢复到原来的A如果入门A [英] Managing the Activity Lifecycle demo activity return to original A if Start A
问题描述
我想通过 HTTPS提供的演示://开发商。 android.com/training/basics/activity-lifecycle/index.html 。
我可以看到当我开始B或C,一个新的活动B或C将被创建,如果我完成B或C也将只有一个退步,就像:创建A-> B-> C- > B-> C,然后通过完成C,那么B,则C,那么BI将得到一个。
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.
虽然如果我尝试启动的过程中,它会去到原来的第一个A,只喜欢: 创建A-> B-> C,然后创建一个,它只是成为一个(而不是A-> B-> C-> 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).
在code的活动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?
推荐答案
这是因为 launchMode
的活动A是singleTask。活动> 标记此获取下一个活动的&LT AndroidManifest.xml文件中声明。从这个文件,你可以修改你的活动行为,服务等的从文档:
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:
在此相反,singleTask和singleInstance活动只能 开始的任务。它们总是在活动堆的根。 此外,该装置可以在一个保持活动的一个实例 时间 - 只有一个这样的任务
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.
这篇关于管理活动生命周期的演示活动恢复到原来的A如果入门A的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!