我正在努力理解Android中对任务亲和力的需求。我还搜索了其他的答案。
我特别感兴趣的是singleTask启动模式和任务关联的结合。
对于singleTask启动模式(带有NEW_TASK标志的OR意图),系统采取以下三个操作之一:
我有点理解这个回答的第一个例子的必要性。它讨论了在多个状态下具有相同的活动,以及它如何在用户体验中造成不一致的问题。
我更困惑的是第二种情况--为什么系统需要找到一个具有同样亲和力的现有任务?如果这个特性不被允许的话,它实现了什么类型的用例并且会中断呢?为什么有这个必要?
从这个链接
... if the intent passed to startActivity() contains the
FLAG_ACTIVITY_NEW_TASK flag, the system looks for a different task to
house the new activity. Often, it's a new task. However, it doesn't have to be.
If there's already an existing task with the same affinity as the new activity, the
activity is launched into that task. If not, it begins a new task.同样的链接也谈到了task reparenting。这是另一个我无法理解的特性。这个链接确实给出了一个天气/旅行应用程序的例子:
... suppose that an activity that reports weather conditions in selected cities
is defined as part of a travel application. It has the same affinity as other
activities in the same application (the default application affinity) and it allows
re-parenting with this attribute. When one of your activities starts the weather
reporter activity, it initially belongs to the same task as your activity.
However, when the travel application's task comes to the foreground, the weather
reporter activity is reassigned to that task and displayed within it.我对于这个特性的问题也是类似的。我无法判断这个特性是为了满足某些必要的用户体验需求,还是仅仅是对任务的一种奇特的附加呢?为什么活动需要在不同的任务中被重新亲生?
有谁能帮我回答以上两个问题吗?
发布于 2015-08-20 21:11:06
我要试试这个!
我相信Android/Google的意图是为用户提供无缝的交互。
所以当我读到关于亲和力的文章时,脑海中浮现的是URL、电子邮件、文档等等。问用户要打开什么应用程序是有意义的,特别是如果他们已经打开了一个应用程序,可以处理这个意图。
再为人父母也是如此。该任务打开另一个应用程序,但是当用户完成该任务并希望返回到原始应用程序时会发生什么情况?从用户的角度来看,无论需要多少应用程序来满足这种体验,它都是一种体验。
(我发誓我在Android的材料设计博士中读到了这个.)
https://stackoverflow.com/questions/32127624
复制相似问题