I have a list activity in which the user can do open action modes A and B. The user can also open action mode A then B on top of it.
The problem is that when action mode A is shown and action mode B is shown on top of it, A gets closed automatically when B is shown. The user can't navigate back from B to A.
I thought I could take note of action mode A visibility when action mode B is opened then restore it when action mode B is closed, but that doesn't work. It seems that it's not possible to immediately show another action mode after closing one. However this issue only happens if the action mode A is closed with the back arrow. When closed by code (ActionMode.finish()), action mode B can be shown, but the closing animation doesn't make it look like user is navigating back from B to A. So this solution is out of question.
So is there a way to open an action mode on top of another, or at least replace the menu layout of an action mode programatically then change it back?
Action mode A is actually the search action mode, from which the user can select results which opens action mode B if that can help to understand.
I think I reached desired behavior through postDelayed() from onDestroyActionMode of action mode B. This is not very elegant solution, but it works.
My code snippet: