首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Android -需要任务关联、单个任务启动模式和任务修复

Android -需要任务关联、单个任务启动模式和任务修复
EN

Stack Overflow用户
提问于 2015-08-20 20:20:40
回答 1查看 840关注 0票数 0

我正在努力理解Android中对任务亲和力的需求。我还搜索了其他的答案。

我特别感兴趣的是singleTask启动模式和任务关联的结合。

对于singleTask启动模式(带有NEW_TASK标志的OR意图),系统采取以下三个操作之一:

  1. 如果存在活动,它将恢复活动。
  2. 如果活动不存在,它将查找具有匹配关联的任务来添加该活动。
  3. 如果没有找到匹配的任务,系统将创建一个新任务,并将此活动作为根。

我有点理解这个回答的第一个例子的必要性。它讨论了在多个状态下具有相同的活动,以及它如何在用户体验中造成不一致的问题。

我更困惑的是第二种情况--为什么系统需要找到一个具有同样亲和力的现有任务?如果这个特性不被允许的话,它实现了什么类型的用例并且会中断呢?为什么有这个必要?

从这个链接

代码语言:javascript
复制
... 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。这是另一个我无法理解的特性。这个链接确实给出了一个天气/旅行应用程序的例子:

代码语言:javascript
复制
... 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.

我对于这个特性的问题也是类似的。我无法判断这个特性是为了满足某些必要的用户体验需求,还是仅仅是对任务的一种奇特的附加呢?为什么活动需要在不同的任务中被重新亲生?

有谁能帮我回答以上两个问题吗?

EN

回答 1

Stack Overflow用户

发布于 2015-08-20 21:11:06

我要试试这个!

我相信Android/Google的意图是为用户提供无缝的交互。

所以当我读到关于亲和力的文章时,脑海中浮现的是URL、电子邮件、文档等等。问用户要打开什么应用程序是有意义的,特别是如果他们已经打开了一个应用程序,可以处理这个意图。

再为人父母也是如此。该任务打开另一个应用程序,但是当用户完成该任务并希望返回到原始应用程序时会发生什么情况?从用户的角度来看,无论需要多少应用程序来满足这种体验,它都是一种体验。

(我发誓我在Android的材料设计博士中读到了这个.)

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32127624

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档