如何在点击一个按钮完成多种活动? [英] How to finish multiple activities on a button click?
问题描述
我实现Android应用程序是基于Web的服务。我创建登录活动A
然后网页 b活动
等等。
假设有A,B,C,D和E等活动。我在活动è
键,通过点击该活动E,D和C
要完成并创建一个主页按钮家庭 b活动
应该恢复。
我怎么能实现呢?
A> B> C> D> E>后退按钮在电子商务 活动>乙。
看看的<一个href="http://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_CLEAR_TOP"><$c$c>FLAG_ACTIVITY_CLEAR_TOP$c$c>标志。
在本质上它执行以下操作。如果活动
此意图
是针对暂停在当前后退堆栈然后将恢复它并清除栈它上面摧毁所有的活动,它上面的堆栈。
更新:为了应对贾森·汉利
感谢您提到它。 FLAG_ACTIVITY_CLEAR_TOP
的文件覆盖了例子。如果你不想让 b活动
来重新创建,但刚刚通过新的意图
,那么你应该确定其发射方式为 singleTop
。
I am implementing android application which is on web service. I'm creating login Activity A
then homepage Activity B
and so on.
Suppose there are A, B, C, D and E etc. activities. I'm creating a home button in Activity E
and by clicking on that Activity E, D and C
should finish and home Activity B
should resume.
How can I implement that?
A > B > C > D > E > back button in E Activity > B.
Take a look at the FLAG_ACTIVITY_CLEAR_TOP
flag.
In essence it does the following. If the Activity
this Intent
is directed to is paused in your current back stack then it will resume it and clear the stack above it destroying all the activities in the stack above it.
UPDATE: In response to Jason Hanley.
Thanks for mentioning it. The documentation of FLAG_ACTIVITY_CLEAR_TOP
covers that example. If you don't want Activity B
to be recreated but just passed the new Intent
then you should define its launch mode as singleTop
.
这篇关于如何在点击一个按钮完成多种活动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!