I encountered that the method getSearchableInfo always returns null during SearchView initialization if I use the packageNameSuffix in
I am using product flavors that completely changes the package name. I found that by using the ComponentName(Context pkg, Class> cls) constructor for my search activity I get a valid SearchableInfo.
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
SearchableInfo searchableInfo = searchManager.getSearchableInfo(new ComponentName(this, SearchActivity.class));
I also had to adjust my provider to use a different package so my searchable xml is in each flavor directory and the provider is listed in the manifest for each flavor as well. This is my directory structure:
src
main
AndoridManifest.xml
flavor1
res
xml
search.xml
AndroidManifest.xml
flavor2
res
xml
search.xml
AndroidManifest.xml
main/AndroidManifest.xml
flavor1/AndroidManifest.xml
flavor1/res/xml/search.xml
flavor2/AndroidManifest.xml
flavor2/res/xml/search.xml