Although this is tedious, it can be done by starting with the Activity methods startActivityForResult (), setResult (), finish () and onActivityResult ().
In pseudo code:
A: startActivityForResult(B)
B: startActivityForResult(C)
C: startActivity(D); setResult(CLEAR); finish()
D: ...
B: (onActivityResult) setResult(CLEAR); finish()
A: (onActivityResult) finish()
If you want to change your architecture, a more natural way to do this is to use FLAG_ACTIVITY_CLEAR_TOP for a simple transition from A, B, C to just A.
- A, B C, noHistory, C B A.