Try removing the activity.finish line totally from the sub.
Normally you would open activities in a stack order, and the natural operation of the back button would be to reverse that stack order by closing the current activity, so the previous activity in the stack is shown.
But you want to conditionally control which activity gets shown when the back button is pressed. So, you will have to manually keep track of your desired order and implement a back-key override routine (like you are doing above) in all relevant activities so it will keep the unstack order you desire.