I have an application that goes as follows (Home being the launch activity):
D
C
B
A
Home
My flow goes as follows:
The user starts activity A from Home, which flows to B and C. When the user leaves activity C, I want A, B, and C to be destroyed. That is, if the user presses BACK in activity D, it goes back to Home.
The user must be able to control program flow normally through activityA, B, and C. So if they press the back button in activityC, it goes back to activity B.
I’ve looked at Intent flags such as CLEAR_TOP and NEW_TASK, but none of them seem to do what I want them to.
I’d appreciate any help!
Perhaps you are looking for
FLAG_ACTIVITY_TASK_ON_HOME? It requires API level 11 though 🙁for API level <11, this can be done:
when starting activity B and C, use startActivityForResult(). When starting activity D, do this:
This will kill activity C. Then in activity A and B, override onActivityResult like this:
Thus activity B will finish, which in turn will trigger onActivityResult in A, so it will also finish.