Set search hint dynamically-Collection of common programming errors
-
In the manifest the dummy activity was associated with the new searchable2.xml:
-
In ‘MainActivity’ I overrode ‘onSearchRequested()’ to reference the appropriate searchable activity:
public boolean onSearchRequested() { SearchManager searchManager = (SearchManager)getSystemService(Context.SEARCH_SERVICE);
if(searchManager!=null) { // start the search with the appropriate searchable activity // so we get the correct search hint in the search dialog if(/* your condition here */) searchManager.startSearch(null, false,new ComponentName(this, MainActivity.class), null, false); else searchManager.startSearch(null, false,new ComponentName(this, DummyActivity.class), null, false);
return true; } return false; }