Specify something like this in your AndroidManifest file:
<activity android:name="ActivityA">
<intent-filter>
<action android:name="android.intent.action.MAIN"/
>
<category
android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<meta-data android:name="android.app.default_searchable"
android:value=".ActivityB" />
</activity>
<activity android:name="ActivityB">
<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" /
>
</activity>
Create a searchable.xml file in the res/xml folder:
<searchable xmlns:android="http://schemas.android.com/apk/res/
android"
android:label="@string/search_label"
android:hint="@string/search_hint">
</searchable>
In onCreate() function in ActivityB, handle the ACTION_SEARCH intent:
final Intent queryIntent = getIntent();
final String queryAction = queryIntent.getAction();
if (Intent.ACTION_SEARCH.equals(queryAction)) {
String s = queryIntent.getStringExtra
(SearchManager.QUERY));
}
--
Jack Ha
Open Source Development Center
·T· · ·Mobile· stick together
The coverage you need at the price you want
The views, opinions and statements in this email are those of
the author solely in their individual capacity, and do not
necessarily represent those of T-Mobile USA, Inc.
On Sep 11, 3:56 am, mardah <[email protected]> wrote:
> Hi
>
> I'm trying to understand how the SearchManager works. I have one
> activity "Activity A" from which I would like to invoke the Search UI.
> When the user enters a query and clicks search I would like to start a
> new activity "Activity B" that handles the query. How should I
> implement this?
>
> In the
> documentation,http://developer.android.com/reference/android/app/SearchManager.html
>
> 1) If the user launched a search, and this required switching to
> another activity to receive and process the search Intent, your
> activity will receive the normal sequence of activity pause or stop
> notifications.
>
> 2) If the user launched a search, and the current activity is the
> recipient of the search Intent, you will receive notification via the
> onNewIntent() method.
>
> The second use case works but I would like to specify another activity
> to receive and process the search Intent.
>
> BR
> Martin
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---