tags:

views:

37

answers:

1

Hi,

I am trying to implement search in my application.

My application contain 4 activities and I want to add the search dialog only on 3 of them while only one of them (ProductsActivity) will be the default context.

unfortunately while I activate the search I keep getting the following error: "Key android.app.default_searchable expected String but value was a java.lang.Integer. The default value was returned."

 <activity android:label="@string/app_name" class=".AppEntry" android:name=".AppEntry">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
 </activity>
 <activity android:name=".category.CategoriesListActivity">
    <intent-filter>
        <action android:name="android.intent.action.SEARCH" />
        </intent-filter>
        <meta-data android:name="android.app.searchable" android:resource="@xml/searchable"/>
 </activity>
 <activity android:name=".product.ProductsActivity">
        <intent-filter>
            <action android:name="android.intent.action.SEARCH" />
        </intent-filter>
        <meta-data android:name="android.app.default_searchable" android:resource="@xml/searchable"/>
    </activity>

Any idea why ?

Thanks

A: 

Shouldn't it be

<meta-data android:name="android.app.default_searchable" 
    android:value=".product.ProductsActivity"/>

instead of passing the @xml reference there again.

Mathias Lin
i don't think since without the @xml reference the system default search will be the system context
chen
Have you tried or you're guessing? All the samples i.e. http://developer.android.com/guide/topics/search/search-dialog.html or http://developer.android.com/resources/samples/Wiktionary/AndroidManifest.html use the syntax I mentioned, with android:value and not android:resource passed. I'm only talking about the android.app.default_searchable here, not the android.app.searchable.
Mathias Lin
OK i found what was wrong - I should declare in CategoriesListActivity activity that the default search is the ProductsActivity
chen
<activity android:name=".category.CategoriesListActivity"> <meta-data android:name="android.app.default_searchable" android:value=".product.ProductsActivity"/> </activity> <activity android:name=".product.ProductsActivity"> <intent-filter> <action android:name="android.intent.action.SEARCH" /> </intent-filter> <meta-data android:name="android.app.searchable" android:resource="@xml/searchable"/> </activity>
chen
Thanks for the help
chen