Android中的FLAG_ACTIVITY_CLEAR_TOP [英] FLAG_ACTIVITY_CLEAR_TOP in Android

查看:70
本文介绍了Android中的FLAG_ACTIVITY_CLEAR_TOP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以用一种非常简单的方式向我解释FLAG_ACTIVITY_CLEAR_TOP是什么意思吗?我知道对此有很多疑问,但是没有一个答案令我满意.有人可以举个例子说明这个标志有用吗?谢谢.

Can somebody explain me in a really simple way what does FLAG_ACTIVITY_CLEAR_TOP mean? I know there were a lot of questions about it, but none of the answers satisfied me. Can somebody also give an example where this flag is useful? Thanks.

推荐答案

请检查下面的链接,以了解详细信息:

Please check the below link for the details of the same:

http://developer.android.com/reference/android/content/Intent.html

这意味着:假设您有4个活动,A,B,C和D,流程是

What it means is: let's say you have 4 activities, A, B, C, and D, and the flow is

A-> B-> C-> D

A -> B -> C -> D

现在,当您在D上时,要启动活动B(从堆栈而不是新实例),那么可以使用此intent标志.同样,它所做的是删除B顶部的所有其他活动(此处为C和D).

and now when you are on D you want to start activity B (from the stack and not a new instance) then you can use this intent flag. Also what it does is remove all the other activities on top of B (here C and D).

一个实时示例是带有活动的电子邮件应用程序 ReadMailInInbox-> OpenMailFullScreen-> ReplyMail回复邮件后,您将不希望返回OpenMailFullScreen,而是希望您的ReadMailInInbox活动位于顶部,因此您可以通过传递带有设置为FLAG_ACTIVITY_CLEAR_TOP的标志的意图来启动此活动.

A realtime example would be an email app with activities ReadMailInInbox -> OpenMailFullScreen -> ReplyMail once you reply to your mail you wont want to go back to OpenMailFullScreen rather you would want your ReadMailInInbox activity to come on top so you can start this activity by passing an intent with the flag set as FLAG_ACTIVITY_CLEAR_TOP.

希望这会有所帮助.

这篇关于Android中的FLAG_ACTIVITY_CLEAR_TOP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆