开发者

FLAG_ACTIVITY_CLEAR_TOP in Android

开发者 https://www.devze.com 2023-04-04 09:55 出处:网络
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 somebod

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

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

A -> 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).

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消