My Activity backstack structure looks like this:
A(Landing page) -> B(List screen) -> C(Details screen)
|----> D(Post item screen) -> E(Post result screen)
Both B & D are direct child of A.
I wanted to provide a way for user to view the detail(C) from the result screen(E). While they go away, I wanted to remove D & E so that they can't go back when pressing back. Once jumped when user press back from C then they should go back to A instead.
EDIT: However, user can press back on E screen to go back and make change in D screen to fix whatever mistake they made so I kinda have to keep D in backstack as well.
What is the best way of doing this? Should I prevent D&E from ever going into backstack and handle my own navigation? Is there a way to clear D & E specifically and keep everything else? Or is there a better way to do this?
I considered using Clear Top
flag but if user never visits C before Clear top wouldn't work as you can't go back to A afterward.
I use Activity.finish() to hide a Activity from the backstack.
As an example:
The user sees activity B and starts activity C. After stating of C call finish to hide B from the backstack:
startActivity(<Activity-C intent>);
finish();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.