Android pushes new activities when other activities are cleared

I have a series of activities a, B and C. After completion, I need to push the new activity y to my family activities. The task stack should be as follows

> H. > H-> A > H-> A-> B > H-> A-> B-> C. > H-> Y.

I need the back button to go back from C to B or B to a, but then C "completes" I need to do y is the active task. Y's "back" needs to go home (H)

thank you.

resolvent:

Jamie, do Android things now? What a terrible idea! In any case, finish () is your friend when deleting activities from the stack. You can call it multiple times to pop multiple activities from the stack

Alternatively, you can pass flag in the intent_ ACTIVITY_ CLEAR_ Top flag to erase the entire stack (but it sounds like you want to keep h, so this may not be a wise choice)

By the way, one thing I haven't played is flag_ ACTIVITY_ NEW_ Task, but this may apply to your situation. Pass it before starting A. although it may be completely useless in your case, just try it a little

Editor: after playing for a while, calling finish () several times actually didn't work as expected. I used flag_ ACTIVITY_ CLEAR_ TOP starts H, and immediately starts Y (that is, calling two startActivity in one function) to make it work.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>