开发者

How to clear current activities in the stack?

Support App starts activity A, then A starts activity B and finishes itself. After that activity B starts activity C.

Now the stack contains B and C, with C at the top.

Then I click开发者_StackOverflow中文版 a button in activity C, and want it to clear B and C and start activity A, i.e. I want activity A to be the only activity in the stack. How can I make it?

Edit: I made a test to use FLAG_ACTIVITY_CLEAR_TOP. But it didn't work in my case, because activity A is not running when button in activity C is clicked.


Set the FLAG_ACTIVITY_CLEAR_TOP flag on your intent to start activity A.

Edit: Is there a reason you can't leave A going? Then you could do as suggested.

Otherwise, another (more complicated) option:

In B start C forResult. When A is started from C, you could finish C with a result indicating to B to also exit.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜