Find out the reason of destruction of action mode android

768 Views Asked by At

I am using action mode to display some menu options depending upon the context. I am using ActionMode.Callback interface to listen to action mode events. onDestroyActionMode(ActionMode mode) is called every time an action mode is destroyed.

For example,

1)When hardware back button is pressed

2)When back arrow icon in action mode toolbar is pressed

3)On orientation change

4)By calling actionMode.finish()

I want to know why the action mode was destroyed. Because if action mode was destroyed by user pressing back button or a back arrow in the action mode toolbar, then I want to perform a different set of actions. How do I know the reason for destruction of action mode?

1

There are 1 best solutions below

0
On

Maybe you could go the other way around, override onBackPressed() and check if the actionMode is displayed when the user pressed back?