简体   繁体   中英

Move to parent activity without finishing child activity using back button

Is it possible to go one activity back without finishing the one you're leaving? In my android app, I have a drawer activity, which with a drawer item click opens a new activity. However, when I try to move back to the drawer activity using the back button, the newly opened activity is destroyed. Is it possible to move that activity back so it runs in background?

Move from drawer activity to next activity by setting the flag to clear the stack and now stack only has one activity which need to run in background now open drawer activity.

ie

A => drawer activity

B => activity which need to run in background

Step-1

open A

now stack has only A


Step-2

move from A -> B by clearing the flag

now stack has only B


Step-3

move from B -> A

now stack has only B and A. A is on top of stack and B is still in stack

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM