开发者

How to clear current activities in the stack?

开发者 https://www.devze.com 2023-01-09 12:06 出处:网络
Support App starts activity A, then A starts activity B and finishes itself. After that activity B starts activity C.

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

精彩评论

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