In my android app I am stacking different instances of the same activity over top of each other (it is a requirement and I cannot change that).
I also have a close button on my activity's toolbar where the current functionality is that if user clicks on the close button it will close the current instance of the activity. Back button also have the same functionality.
But I want to change this behaviour. The back button should work the same way it is working now (finish the current instance) but the close button should finish all the instances of that activity and return to the parent activity where the transition started.
I cannot use the intent flags like Intent.FLAG_ACTIVITY_CLEAR_TOP
or Intent.FLAG_ACTIVITY_SINGLE_TOP
because then the back button will also close all the instances of the activity.
I need something on theonOptionsItemSelected
which close the activity and return to the parent activity. Please provide any hint if you can. Thanks