tags:

views:

125

answers:

1

I have a button in my app. When it is pressed I call the onSearchRequested() method. When this is called the stock search box comes up so the user can type some junk in there. When they press "Go" I need the results returned back to my application but instead the stock browser is opened and a google search is performed. How can I tell it to return the results to my application instead.

I've tried these items in my manifest.xml file:

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

<activity android:name=".MainActivity"
android:launchMode="singleTop"

<intent-filter>
<action android:name="android.intent.action.SEARCH" />                         
</intent-filter>

I've also tried to capture the result in my onCreate with this:

Intent intent = getIntent();        
if (Intent.ACTION_SEARCH.equals(intent.getAction())) 
A: 

This is covered fairly well in the documentation. In particular, you are missing the searchable <meta-data> element (and, presumably, the corresponding XML file). Here is a sample project showing the use of search within an application.

CommonsWare
I was creating my app from a sample similar to that one. I've tested your demo out and it does work, so it's just a matter of me getting the right peices moved over i suppose. I'll keep you updated.
pcm2a