views:

244

answers:

1

Right now I'm adding

<intent-filter>
 <action android:name="android.intent.action.SEARCH" />
 <category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data android:name="android.app.searchable" android:resource="@xml/searchable" />

to every single <activity> in the AndroidManifest.xml, receive the Intent in each activity and forward the search string to one singleTop activity that actually performs the search (via HTTP/JSON) and displays the results in a list.

I'm wondering if there's a way how I can set-up the AndroidManifest.xml, so that search is activated in each activity within my application, but the search string will get forwarded from Android's search box directly to my singleTop SearchResults_Activity instead of going the way through validating events in each activity and then forwarding the search string.

+1  A: 

The answer to that is actually available in the SearchManager documentation, in the MetaData chapter.

Activities which are part of a searchable application, but don't implement search itself, require a bit of "glue" in order to cause them to invoke search using your searchable activity as their primary context. If this is not provided, then searches from these activities will use the system default search context.

<application>
    <meta-data android:name="android.app.default_searchable"
       android:value=".MySearchActivity" />

    <!-- followed by activities, providers, etc... -->
</application>
znq