views:

15

answers:

0

I have an Android app which has a few different activities for browsing articles and images downloaded from RSS.

I'd like to be able to offer to hook up the search button to the Search dialog, using the a searchable.xml file. I've managed to do this with one search, using:

    <activity android:name=".search.SearchResultsActivity"
              android:label="@string/search_results_activity_title" >
        <intent-filter>
            <action android:name="android.intent.action.SEARCH" />
        </intent-filter>
        <meta-data android:name="android.app.searchable"
                   android:resource="@xml/searchable_articles"/>
    </activity>

and in the <application />

    <meta-data android:name="android.app.default_searchable"
               android:value=".search.SearchResultsActivity" />

I can now launch the Search dialog from any activity, and it launches the SearchResultsActivity.

I would now like to be able to search for images when the user is an ImageListActivity, using a searchable_images.xml, and use the default everywhere else.

I have a SearchResultsImageActivity which includes the following meta-data element, and used the same element in the ImageListActivity.

        <meta-data android:name="android.app.searchable"
                   android:resource="@xml/searchable_images"/>

On pressing the search button in the ImageListActivity, I get the default search from searchable_articles.xml.

If I change the default_searchable to SearchResultsImageActivity, the image search is always launched, and the article search is never launched.

If I remove the default_searchable meta-data element altogether, and add searchable meta-data only selected activities, no search is launched.

I'm fairly sure this should be possible, but I don't know what I'm doing wrong.