Imagine this activity history stack:
A > B > C > D > E
scenario 1:
If the user is on E then on tapping the back button it should navigate to D > C > B > A.
scenario 2:
If the user is on E then on tapping a custom button "Show B", then it should clear E > D > C. Which is similar to Finish().
Like X > Y if we set finish on Y the X will be displayed. Similar If I tape Show B on E then E > D > C should be cleared from the stack.
I need to achieve both scenarios.
(Edited ^^^^ with scenarios)
If the user is on E activity and wants to move B. If B is in history stack can we clear C > D > E so that user can navigate to B without startActivity(B). and A should be in history.
If an activity is available in the stack then it should load from history if not startActivity(B).
If I use FLAG_ACTIVITY_CLEAR_TOP/FLAG_ACTIVITY_NEW_TASK, it will clear full history and start's new activity.
I want to clear partial history.
Will it be possible to achieve? If so, how to do it please?