This is how I navigate through my app:
I see you didn't find a solution yet, I have same problem posted here:
I found that when invalidateOptionsMenu
is called also the method onQueryTextChange
is called because the View launch dispatchRestoreInstanceState
with the previous value after you've cleared the search for example. Do you call invalidateOptionsMenu
maybe?
Maybe, inside onQueryTextChange
, you can check a boolean on some current state of your application objects to know if the method content should be executed. In my case I use mDrawerLayout.isDrawerOpen(..)
to allow the search.
Also you can implement the SearchView.OnQueryTextListener
on each Class you use, on a Fragment
or on the Main Activity class, somewhere in the class you could set a boolean module variable that you will check inside onQueryTextChange.