How to declare 2 search activities in android manifest
I am trying to implement two different searchable activities, one for honeycomb(with search widget) and others for non-honeycomb(with search dialog).
My Manifest looks like:
<activity android:name=".activities.Search"
android:theme="@style/NoTitleTheme"
android:configChanges="orientation|keyboardHidden"
android:launchMode="singleTop">
android:enabled="@bool/disableForNonHoneycomb"
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<meta-data android:name="android.app.searchable"
android:resource="@xml/searchable"
android:value=".activities.Search"/>
</activity>
<activity android:name=".activities.SearchHoneycomb"
android:theme="@style/CustomTheme"
android:configChanges="orientation|keyboardHidden"
android:enabled="@bool/enableForNonHoneycomb"
android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<meta-data android:name="android.app.searchable"
android:resource="@xml/searchable"
android:value=".activities.SearchHoneycomb"/>
</activity>
And, I use following code to get the searchable configuration and set up the search view in my activity.
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
_searchView = (SearchView) mCustomView.findViewById(R.id.action_bar_searchwidget);
_searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
Proble开发者_C百科m is that when I use the search widget, it does not start the SearchHoneycomb activity. How can I make this work?
Thanks.
So, after a lot of investigation... there is no way to have 2 searchable activities as android manifest only accepts 1 meta-data for default-searchable. I got a work around by using a search dialog with default-searchable meta-data and the implemented the querytextlistener for search widget.
精彩评论