简体   繁体   English

我想对不同的活动发布模式做一些澄清

[英]I would love some clarification on the different Activity launch modes

I'm trying to make sense of, but failing to, the documentation's distinction between singleTask and singleInstance. 我试图理解,但没有,文档区分singleTask和singleInstance。 They both look like singletons to me. 他们对我来说都像单身人士。 Could someone please elaborate on how they're different and maybe note an example of where one might choose to use one over the other? 有人可以详细说明它们是如何不同的,也许还要注意一个人可能选择使用哪一个而不是另一个的例子? I don't need an explanation of the singleTop and the default launchMode, I'm only confused about these two. 我不需要解释singleTop和默认的launchMode,我只是对这两个问题感到困惑。

From the documentation : The "singleTask" and "singleInstance" modes also differ from each other in only one respect: A "singleTask" activity allows other activities to be part of its task. 文档中 :“singleTask”和“singleInstance”模式在一个方面也各不相同:“singleTask”活动允许其他活动成为其任务的一部分。 It's always at the root of its task, but other activities (necessarily "standard" and "singleTop" activities) can be launched into that task. 它始终是其任务的根源,但其他活动(必然是“标准”和“单一活动”)可以启动到该任务中。 A "singleInstance" activity, on the other hand, permits no other activities to be part of its task. 另一方面,“singleInstance”活动不允许其他活动成为其任务的一部分。 It's the only activity in the task. 这是任务中唯一的活动。 If it starts another activity, that activity is assigned to a different task — as if FLAG_ACTIVITY_NEW_TASK was in the intent. 如果它启动另一个活动,则该活动将分配给另一个任务 - 就像FLAG_ACTIVITY_NEW_TASK在意图中一样。

Does that answer your question, or do you need more clarification? 这是回答你的问题,还是需要更多澄清?

Have a look here for an explanation of what a "task" is in Android. 看看这里解释Android中的“任务”是什么。 Perhaps that will help you understand. 也许这会帮助你理解。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM