Android的任务亲和说明 [英] Android Task Affinity Explanation
问题描述
到底是什么属性 taskAffinity
用的呢?我已经通过了<一走href="http://developer.android.com/guide/topics/manifest/activity-element.html#aff">documentation但我不明白了。
What exactly is the attribute taskAffinity
used for? I have gone through the documentation but I couldn't understand much.
谁能解释的任务亲和力深入浅出方面?
Can anyone explain task affinity in laymans terms?
推荐答案
什么是Android的任务亲和使用?
一个Android应用程序有形成一叠像一副扑克牌活动。如果你开始一个Android应用程序,并启动五项活动A,B,C,D,E。它们会形成堆叠
An android application has Activities that form a stack like a deck of cards. If you start an android application, and start five activities A,B,C,D,E. They will form a stack
E - chat view
D - weather screen
C - map view
B - weather screen
A - login screen
电子是最后活动将启动,它显示。如果您关闭E,D将显示。如果关闭D,C将显示。等等。
E was the last Activity to be started and it is showing. If you close E, D will be shown. If you close D, C will be shown. etc.
请注意,活动 B
和 D
是相同的活动。如果那用户要进行一些修改 D天气屏幕
,然后决定关闭活动,然后关闭ç地图视图
?
Notice that Activities B
and D
are the same activity. What if the user were to make some modifications to the D weather screen
, and then decided to close the activity, then close the C Map view
?
然后,用户将回到天气屏幕,用户会不高兴,因为在一级 D天气屏幕
所做的更改都不会保存在一级 B的天气屏幕
。虽然是同样的活动,这是一个不同的状态的活动。
Then the user would be back at the weather screen and the user would be unhappy because the changes made at level D weather screen
were not saved in level B weather screen
. Although it's the same activity, it's a different STATE of that activity.
用户有活动,有5层堆叠,其中两个是一样的活动。膨化所有5折的堆栈将产生的现象在这里您将有两个不同版本的同一活动的互动,可以相当混乱。
The user had a 5 layer stack of activities, and two of them were the same activity. Popping all 5 off the stack will create the phenomenon where you will be interacting with two different versions of the same activity and can be quite confusing.
用户通常不会想到在活动刚性栈方面。他们认为:嚯天气认为我会做出改变那里,然后他们要回去的地图视图。然后再次备份,因为他们想回到登录页面。为什么 B的天气应用程序
显示,为什么不从级别保存设置 D
?
Users don't usually think in terms of a rigid stack of activities. They think: "ooh the weather view I'll make a change there" and then they want to go back to the Map view. Then back up again because they want to go back to the Login screen. Why is the B weather app
showing and why didn't it save the settings from level D
?
程序员也许能够减轻一些混乱,如果活动 B
和 D
是在状态联系在一起。这种方式改变为一个人改变另一个。用户打开了一个新的气象屏幕每一次,偷偷打开天气屏幕的单个实例。
The programmer might be able to alleviate some confusion if Activities B
and D
were linked in state. That way changes to one changes the other. Each time the user opens up a new weather screen, it secretly opens the single instance of the weather screen.
在这种情况下,改变活动的taskAffinity可能是可取的。用户将更改级别D.然后备份到B级。而且看到D.所做的更改B中
In these circumstances, changing the taskAffinity of the Activity might be desirable. The user would change level D. Then back up to level B. And see the changes in B that were made to D.
该计划保持一个堆栈,你可以通过备份,这是很好的,并且当用户打开了同一活动的x的实例在随机的地方,他们都是之一。
The program keeps a stack you can backup through, which is nice, and when the user opens up X instances of the same activity in random places, they are all one.
有更多的解释幻灯片: <一href="http://www.slideshare.net/RanNachmany/manipulating-android-tasks-and-back-stack">http://www.slideshare.net/RanNachmany/manipulating-android-tasks-and-back-stack
Slideshow with more explanation: http://www.slideshare.net/RanNachmany/manipulating-android-tasks-and-back-stack
这篇关于Android的任务亲和说明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!