Search Bar Widget Not Starting Searchable Activity
Solution 1:
The tutorials seems to missing one important part. You have to add <meta-data android:name="android.app.default_searchable" android:value=".MySearchActivityName" />
inside <application>
tags.
Solution 2:
I had a similar problem. I was following grokking's tutorial and the activity never opened. I tried the Indrek's solutions I that works for me.
You should be sure that you have the right meta-data under the right parent. The meta-data
<meta-data
android:name="android.app.default_searchable"
android:value=".NameSearchActivity" />
should be under application. The follow meta-data
<meta-data
android:name="android.app.searchable"
android:resource="@xml/searchable" />
should be under the search activity parameter inside AndroidManifest.xml.
In the search Activity I did what it say in the tutorial linked before for managing the activity stack. I hope that this solution works for everyone with the same problem.
Solution 3:
Pau Arlandis Martinez, thank you. Your solution works fine and tutorial with activity stack is helpful. I put into <application>
section this meta-data:
<meta-data
android:name="android.app.default_searchable"
android:value=".NameSearchActivity" />
And I noticed that @Override onQueryTextSubmit method should return false to start searchable activity. Otherwise searchButton on virtual keyboard doesn't work.
Solution 4:
I was having trouble with the SearchView
not launching the SearchActivity
, it turned out to be a package/directory issue.
If the SearchableActivity
is not located in the same directory as the Activity
hosting your SearchView
, you need to change:
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
to
searchView.setSearchableInfo(searchManager.getSearchableInfo(newComponentName(this, SearchableActivity.class)));
Solution 5:
For anyone else who still has this issue, I also came across this issue, if the Searchable Activity extends AppCompatActivity the activity wont start, I changed it to extend Activity instead and it worked.
Post a Comment for "Search Bar Widget Not Starting Searchable Activity"