I have the following stack of activities on an Android application:
A -> B -> C
On C, I can go back home ("A") using startActivity with the Intent.FLAG_ACTIVITY_CLEAR_TOP
and Intent.FLAG_ACTIVITY_SINGLE_TOP
intent flags. This clears the stack out of activities B and C so it's just A. Fine so far; this is my equivalent of "home".
However, I have another section - "E" - and I want it to clear the whole stack except for home ("A"). As in:
Activity stack: A -> B -> C
(User clicks on "E" button)
Activity stack result: A -> E
I've tried using Intent.FLAG_ACTIVITY_NEW_TASK
when opening subsection ("B", "E", etc) but there's no way to clear the previous task it seems. I've also tried Intent.FLAG_ACTIVITY_TASK_ON_HOME
but it doesn't seem to do anything (how do you even set what's "home" anyway?).
Is it possible?