SearchManager.java revision be5b73c5926cbebd508d8323bdeaafa2e048a93c
19066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project/*
29066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Copyright (C) 2007 The Android Open Source Project
39066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
49066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Licensed under the Apache License, Version 2.0 (the "License");
59066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * you may not use this file except in compliance with the License.
69066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * You may obtain a copy of the License at
79066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
89066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *      http://www.apache.org/licenses/LICENSE-2.0
99066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
109066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Unless required by applicable law or agreed to in writing, software
119066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * distributed under the License is distributed on an "AS IS" BASIS,
129066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
139066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * See the License for the specific language governing permissions and
149066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * limitations under the License.
159066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */
169066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
179066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectpackage android.app;
189066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
199066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectimport android.content.ComponentName;
20875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaenimport android.content.ContentResolver;
219066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectimport android.content.Context;
229066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectimport android.content.DialogInterface;
23875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaenimport android.database.Cursor;
24875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaenimport android.net.Uri;
259066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectimport android.os.Bundle;
269066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectimport android.os.Handler;
27875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaenimport android.os.RemoteException;
289066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectimport android.os.ServiceManager;
29875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaenimport android.server.search.SearchableInfo;
308d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringertimport android.util.Log;
319066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectimport android.view.KeyEvent;
32d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaenimport android.text.TextUtils;
339066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
346d72e029cb6e5a9cf26aa3314c3dca83614fc91bBjorn Bringertimport java.util.List;
356d72e029cb6e5a9cf26aa3314c3dca83614fc91bBjorn Bringert
369066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project/**
379066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * This class provides access to the system search services.
389066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
399066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p>In practice, you won't interact with this class directly, as search
409066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * services are provided through methods in {@link android.app.Activity Activity}
419066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * methods and the the {@link android.content.Intent#ACTION_SEARCH ACTION_SEARCH}
429066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * {@link android.content.Intent Intent}.  This class does provide a basic
439066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * overview of search services and how to integrate them with your activities.
448c91dd7ec8b3d277a42bccab075241468c9f980dMike LeBeau * If you do require direct access to the SearchManager, do not instantiate
459066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * this class directly; instead, retrieve it through
469066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * {@link android.content.Context#getSystemService
479066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * context.getSystemService(Context.SEARCH_SERVICE)}.
489066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
499066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p>Topics covered here:
509066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <ol>
519066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li><a href="#DeveloperGuide">Developer Guide</a>
529066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li><a href="#HowSearchIsInvoked">How Search Is Invoked</a>
538c91dd7ec8b3d277a42bccab075241468c9f980dMike LeBeau * <li><a href="#ImplementingSearchForYourApp">Implementing Search for Your App</a>
549066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li><a href="#Suggestions">Search Suggestions</a>
55590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen * <li><a href="#ExposingSearchSuggestionsToQuickSearchBox">Exposing Search Suggestions to
56590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen * Quick Search Box</a></li>
579066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li><a href="#ActionKeys">Action Keys</a>
589066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li><a href="#SearchabilityMetadata">Searchability Metadata</a>
599066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li><a href="#PassingSearchContext">Passing Search Context</a>
609066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li><a href="#ProtectingUserPrivacy">Protecting User Privacy</a>
619066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * </ol>
629066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
639066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <a name="DeveloperGuide"></a>
649066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <h3>Developer Guide</h3>
659066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
669066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p>The ability to search for user, system, or network based data is considered to be
678c91dd7ec8b3d277a42bccab075241468c9f980dMike LeBeau * a core user-level feature of the Android platform.  At any time, the user should be
689066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * able to use a familiar command, button, or keystroke to invoke search, and the user
698c91dd7ec8b3d277a42bccab075241468c9f980dMike LeBeau * should be able to search any data which is available to them.
709066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
718c91dd7ec8b3d277a42bccab075241468c9f980dMike LeBeau * <p>To make search appear to the user as a seamless system-wide feature, the application
728c91dd7ec8b3d277a42bccab075241468c9f980dMike LeBeau * framework centrally controls it, offering APIs to individual applications to control how they
738c91dd7ec8b3d277a42bccab075241468c9f980dMike LeBeau * are searched. Applications can customize how search is invoked, how the search dialog looks,
748c91dd7ec8b3d277a42bccab075241468c9f980dMike LeBeau * and what type of search results are available, including suggestions that are available as the
758c91dd7ec8b3d277a42bccab075241468c9f980dMike LeBeau * user types.
769066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
778c91dd7ec8b3d277a42bccab075241468c9f980dMike LeBeau * <p>Even applications which are not searchable will by default support the invocation of
788c91dd7ec8b3d277a42bccab075241468c9f980dMike LeBeau * search to trigger Quick Search Box, the system's 'global search'.
799066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
809066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <a name="HowSearchIsInvoked"></a>
819066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <h3>How Search Is Invoked</h3>
829066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
839066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p>Unless impossible or inapplicable, all applications should support
849066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * invoking the search UI.  This means that when the user invokes the search command,
859066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * a search UI will be presented to them.  The search command is currently defined as a menu
868c91dd7ec8b3d277a42bccab075241468c9f980dMike LeBeau * item called "Search" (with an alphabetic shortcut key of "S"), or on many devices, a dedicated
879066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * search button key.
888c91dd7ec8b3d277a42bccab075241468c9f980dMike LeBeau * <p>If your application is not inherently searchable, the default implementation will cause
898c91dd7ec8b3d277a42bccab075241468c9f980dMike LeBeau * the search UI to be invoked in a "global search" mode known as Quick Search Box.  As the user
908c91dd7ec8b3d277a42bccab075241468c9f980dMike LeBeau * types, search suggestions from across the device and the web will be surfaced, and if they
918c91dd7ec8b3d277a42bccab075241468c9f980dMike LeBeau * click the "Search" button, this will bring the browser to the front and will launch a web-based
929066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * search.  The user will be able to click the "Back" button and return to your application.
939066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p>In general this is implemented by your activity, or the {@link android.app.Activity Activity}
948c91dd7ec8b3d277a42bccab075241468c9f980dMike LeBeau * base class, which captures the search command and invokes the SearchManager to
959066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * display and operate the search UI.  You can also cause the search UI to be presented in response
969066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * to user keystrokes in your activity (for example, to instantly start filter searching while
979066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * viewing a list and typing any key).
989066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p>The search UI is presented as a floating
999066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * window and does not cause any change in the activity stack.  If the user
1009066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * cancels search, the previous activity re-emerges.  If the user launches a
1019066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * search, this will be done by sending a search {@link android.content.Intent Intent} (see below),
1029066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * and the normal intent-handling sequence will take place (your activity will pause,
1039066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * etc.)
1049066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p><b>What you need to do:</b> First, you should consider the way in which you want to
1059066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * handle invoking search.  There are four broad (and partially overlapping) categories for
1069066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * you to choose from.
1079066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <ul><li>You can capture the search command yourself, by including a <i>search</i>
1089066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * button or menu item - and invoking the search UI directly.</li>
1099066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li>You can provide a <i>type-to-search</i> feature, in which search is invoked automatically
1109066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * when the user enters any characters.</li>
1118c91dd7ec8b3d277a42bccab075241468c9f980dMike LeBeau * <li>Even if your application is not inherently searchable, you can allow global search,
1129066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * via the search key (or even via a search menu item).
1139066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li>You can disable search entirely.  This should only be used in very rare circumstances,
1149066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * as search is a system-wide feature and users will expect it to be available in all contexts.</li>
1159066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * </ul>
1169066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
1179066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p><b>How to define a search menu.</b>  The system provides the following resources which may
1189066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * be useful when adding a search item to your menu:
1199066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <ul><li>android.R.drawable.ic_search_category_default is an icon you can use in your menu.</li>
1209066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li>{@link #MENU_KEY SearchManager.MENU_KEY} is the recommended alphabetic shortcut.</li>
1219066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * </ul>
1229066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
1239066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p><b>How to invoke search directly.</b>  In order to invoke search directly, from a button
1249066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * or menu item, you can launch a generic search by calling
1259066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * {@link android.app.Activity#onSearchRequested onSearchRequested} as shown:
1269066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <pre class="prettyprint">
1279066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * onSearchRequested();</pre>
1289066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
1299066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p><b>How to implement type-to-search.</b>  While setting up your activity, call
1309066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * {@link android.app.Activity#setDefaultKeyMode setDefaultKeyMode}:
1319066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <pre class="prettyprint">
1329066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL);   // search within your activity
1339066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * setDefaultKeyMode(DEFAULT_KEYS_SEARCH_GLOBAL);  // search using platform global search</pre>
1349066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
1358c91dd7ec8b3d277a42bccab075241468c9f980dMike LeBeau * <p><b>How to enable global search with Quick Search Box.</b>  In addition to searching within
1368c91dd7ec8b3d277a42bccab075241468c9f980dMike LeBeau * your activity or application, you can also use the Search Manager to invoke a platform-global
1378c91dd7ec8b3d277a42bccab075241468c9f980dMike LeBeau * search, which uses Quick Search Box to search across the device and the web. There are two ways
1388c91dd7ec8b3d277a42bccab075241468c9f980dMike LeBeau * to do this:
1399066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <ul><li>You can simply define "search" within your application or activity to mean global search.
1409066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * This is described in more detail in the
1419066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <a href="#SearchabilityMetadata">Searchability Metadata</a> section.  Briefly, you will
1429066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * add a single meta-data entry to your manifest, declaring that the default search
1439066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * for your application is "*".  This indicates to the system that no application-specific
1449066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * search activity is provided, and that it should launch web-based search instead.</li>
1458c91dd7ec8b3d277a42bccab075241468c9f980dMike LeBeau * <li>Simply do nothing and the default implementation of
1468c91dd7ec8b3d277a42bccab075241468c9f980dMike LeBeau * {@link android.app.Activity#onSearchRequested} will cause global search to be triggered.
1478c91dd7ec8b3d277a42bccab075241468c9f980dMike LeBeau * (You can also always trigger search via a direct call to {@link android.app.Activity#startSearch}.
1488c91dd7ec8b3d277a42bccab075241468c9f980dMike LeBeau * This is most useful if you wish to provide local searchability <i>and</i> access to global
1498c91dd7ec8b3d277a42bccab075241468c9f980dMike LeBeau * search.)</li></ul>
1509066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
1518c91dd7ec8b3d277a42bccab075241468c9f980dMike LeBeau * <p><b>How to disable search from your activity.</b> Search is a system-wide feature and users
1529066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * will expect it to be available in all contexts.  If your UI design absolutely precludes
1539066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * launching search, override {@link android.app.Activity#onSearchRequested onSearchRequested}
1549066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * as shown:
1559066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <pre class="prettyprint">
1569066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * &#64;Override
1579066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * public boolean onSearchRequested() {
1589066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *    return false;
1599066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * }</pre>
1609066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
1618c91dd7ec8b3d277a42bccab075241468c9f980dMike LeBeau * <p><b>Managing focus and knowing if search is active.</b>  The search UI is not a separate
1629066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * activity, and when the UI is invoked or dismissed, your activity will not typically be paused,
1639066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * resumed, or otherwise notified by the methods defined in
1649066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <a href="{@docRoot}guide/topics/fundamentals.html#actlife">Application Fundamentals:
1659066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Activity Lifecycle</a>.  The search UI is
1669066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * handled in the same way as other system UI elements which may appear from time to time, such as
1679066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * notifications, screen locks, or other system alerts:
1689066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p>When the search UI appears, your activity will lose input focus.
1699066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p>When the search activity is dismissed, there are three possible outcomes:
1709066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <ul><li>If the user simply canceled the search UI, your activity will regain input focus and
1719066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * proceed as before.  See {@link #setOnDismissListener} and {@link #setOnCancelListener} if you
1729066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * required direct notification of search dialog dismissals.</li>
1739066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li>If the user launched a search, and this required switching to another activity to receive
1749066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * and process the search {@link android.content.Intent Intent}, your activity will receive the
1759066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * normal sequence of activity pause or stop notifications.</li>
1769066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li>If the user launched a search, and the current activity is the recipient of the search
1779066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * {@link android.content.Intent Intent}, you will receive notification via the
1789066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * {@link android.app.Activity#onNewIntent onNewIntent()} method.</li></ul>
1799066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p>This list is provided in order to clarify the ways in which your activities will interact with
1809066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * the search UI.  More details on searchable activities and search intents are provided in the
1819066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * sections below.
1829066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
1838c91dd7ec8b3d277a42bccab075241468c9f980dMike LeBeau * <a name="ImplementingSearchForYourApp"></a>
1848c91dd7ec8b3d277a42bccab075241468c9f980dMike LeBeau * <h3>Implementing Search for Your App</h3>
1859066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
1868c91dd7ec8b3d277a42bccab075241468c9f980dMike LeBeau * <p>The following steps are necessary in order to implement search.
1879066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <ul>
1889066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li>Implement search invocation as described above.  (Strictly speaking,
1899066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * these are decoupled, but it would make little sense to be "searchable" but not
1909066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * "search-invoking".)</li>
1919066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li>Your application should have an activity that takes a search string and
1929066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * converts it to a list of results.  This could be your primary display activity
1939066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * or it could be a dedicated search results activity.  This is your <i>searchable</i>
1949066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * activity and every query-search application must have one.</li>
1959066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li>In the searchable activity, in onCreate(), you must receive and handle the
1969066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * {@link android.content.Intent#ACTION_SEARCH ACTION_SEARCH}
1979066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * {@link android.content.Intent Intent}.  The text to search (query string) for is provided by
1989066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * calling
1999066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * {@link #QUERY getStringExtra(SearchManager.QUERY)}.</li>
2009066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li>To identify and support your searchable activity, you'll need to
2019066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * provide an XML file providing searchability configuration parameters, a reference to that
2028c91dd7ec8b3d277a42bccab075241468c9f980dMike LeBeau * in your searchable activity's
2038c91dd7ec8b3d277a42bccab075241468c9f980dMike LeBeau * <a href="{@docRoot}guide/topics/manifest/manifest-intro.html">manifest</a> entry, and an
2048c91dd7ec8b3d277a42bccab075241468c9f980dMike LeBeau * intent-filter declaring that you can receive ACTION_SEARCH intents. This is described in more
2058c91dd7ec8b3d277a42bccab075241468c9f980dMike LeBeau * detail in the <a href="#SearchabilityMetadata">Searchability Metadata</a> section.</li>
2068c91dd7ec8b3d277a42bccab075241468c9f980dMike LeBeau * <li>Your <a href="{@docRoot}guide/topics/manifest/manifest-intro.html">manifest</a> also needs a
2078c91dd7ec8b3d277a42bccab075241468c9f980dMike LeBeau * metadata entry providing a global reference to the searchable activity. This is the "glue"
2088c91dd7ec8b3d277a42bccab075241468c9f980dMike LeBeau * directing the search UI, when invoked from any of your <i>other</i> activities, to use your
2098c91dd7ec8b3d277a42bccab075241468c9f980dMike LeBeau * application as the default search context.  This is also described in more detail in the
2109066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <a href="#SearchabilityMetadata">Searchability Metadata</a> section.</li>
2118c91dd7ec8b3d277a42bccab075241468c9f980dMike LeBeau * <li>Finally, you may want to define your search results activity as single-top with the
2129066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * {@link android.R.attr#launchMode singleTop} launchMode flag.  This allows the system
2139066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * to launch searches from/to the same activity without creating a pile of them on the
2149066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * activity stack.  If you do this, be sure to also override
2159066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * {@link android.app.Activity#onNewIntent onNewIntent} to handle the
2169066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * updated intents (with new queries) as they arrive.</li>
2179066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * </ul>
2189066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
2199066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p>Code snippet showing handling of intents in your search activity:
2209066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <pre class="prettyprint">
2219066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * &#64;Override
2229066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * protected void onCreate(Bundle icicle) {
2239066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     super.onCreate(icicle);
2249066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
2259066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     final Intent queryIntent = getIntent();
2269066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     final String queryAction = queryIntent.getAction();
2279066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     if (Intent.ACTION_SEARCH.equals(queryAction)) {
2289066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *         doSearchWithIntent(queryIntent);
2299066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     }
2309066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * }
2319066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
2329066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * private void doSearchWithIntent(final Intent queryIntent) {
2339066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     final String queryString = queryIntent.getStringExtra(SearchManager.QUERY);
2349066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     doSearchWithQuery(queryString);
2359066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * }</pre>
2369066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
2379066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <a name="Suggestions"></a>
2389066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <h3>Search Suggestions</h3>
2399066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
2408c91dd7ec8b3d277a42bccab075241468c9f980dMike LeBeau * <p>A powerful feature of the search system is the ability of any application to easily provide
2419066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * live "suggestions" in order to prompt the user.  Each application implements suggestions in a
2429066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * different, unique, and appropriate way.  Suggestions be drawn from many sources, including but
2439066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * not limited to:
2449066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <ul>
2459066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li>Actual searchable results (e.g. names in the address book)</li>
2469066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li>Recently entered queries</li>
2479066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li>Recently viewed data or results</li>
2489066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li>Contextually appropriate queries or results</li>
2499066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li>Summaries of possible results</li>
2509066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * </ul>
2519066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
252590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen * <p>Once an application is configured to provide search suggestions, those same suggestions can
253590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen * easily be made available to the system-wide Quick Search Box, providing faster access to its
25405b775e0b7180e33df0303b9e132931f4895357cMike LeBeau * content from one central prominent place. See
255590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen * <a href="#ExposingSearchSuggestionsToQuickSearchBox">Exposing Search Suggestions to Quick Search
256590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen * Box</a> for more details.
257590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *
2589066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p>The primary form of suggestions is known as <i>queried suggestions</i> and is based on query
2599066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * text that the user has already typed.  This would generally be based on partial matches in
2609066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * the available data.  In certain situations - for example, when no query text has been typed yet -
2619066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * an application may also opt to provide <i>zero-query suggestions</i>.
2629066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * These would typically be drawn from the same data source, but because no partial query text is
2639066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * available, they should be weighted based on other factors - for example, most recent queries
2649066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * or most recent results.
2659066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
2668c91dd7ec8b3d277a42bccab075241468c9f980dMike LeBeau * <p><b>Overview of how suggestions are provided.</b>  Suggestions are accessed via a
2678c91dd7ec8b3d277a42bccab075241468c9f980dMike LeBeau * {@link android.content.ContentProvider Content Provider}. When the search manager identifies a
2689066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * particular activity as searchable, it will check for certain metadata which indicates that
2699066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * there is also a source of suggestions.  If suggestions are provided, the following steps are
2709066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * taken.
2719066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <ul><li>Using formatting information found in the metadata, the user's query text (whatever
2729066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * has been typed so far) will be formatted into a query and sent to the suggestions
2739066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * {@link android.content.ContentProvider Content Provider}.</li>
2749066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li>The suggestions {@link android.content.ContentProvider Content Provider} will create a
2759066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * {@link android.database.Cursor Cursor} which can iterate over the possible suggestions.</li>
2769066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li>The search manager will populate a list using display data found in each row of the cursor,
2779066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * and display these suggestions to the user.</li>
2789066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li>If the user types another key, or changes the query in any way, the above steps are repeated
2799066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * and the suggestions list is updated or repopulated.</li>
2809066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li>If the user clicks or touches the "GO" button, the suggestions are ignored and the search is
2819066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * launched using the normal {@link android.content.Intent#ACTION_SEARCH ACTION_SEARCH} type of
2829066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * {@link android.content.Intent Intent}.</li>
2839066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li>If the user uses the directional controls to navigate the focus into the suggestions list,
2849066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * the query text will be updated while the user navigates from suggestion to suggestion.  The user
2859066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * can then click or touch the updated query and edit it further.  If the user navigates back to
2869066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * the edit field, the original typed query is restored.</li>
2879066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li>If the user clicks or touches a particular suggestion, then a combination of data from the
2889066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * cursor and
2899066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * values found in the metadata are used to synthesize an Intent and send it to the application.
2909066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Depending on the design of the activity and the way it implements search, this might be a
2919066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * {@link android.content.Intent#ACTION_SEARCH ACTION_SEARCH} (in order to launch a query), or it
2929066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * might be a {@link android.content.Intent#ACTION_VIEW ACTION_VIEW}, in order to proceed directly
2939066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * to display of specific data.</li>
2949066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * </ul>
2959066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
2969066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p><b>Simple Recent-Query-Based Suggestions.</b>  The Android framework provides a simple Search
2979066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Suggestions provider, which simply records and replays recent queries.  For many applications,
2989066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * this will be sufficient.  The basic steps you will need to
2999066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * do, in order to use the built-in recent queries suggestions provider, are as follows:
3009066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <ul>
3019066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li>Implement and test query search, as described in the previous sections.</li>
3029066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li>Create a Provider within your application by extending
3039066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * {@link android.content.SearchRecentSuggestionsProvider}.</li>
3049066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li>Create a manifest entry describing your provider.</li>
3059066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li>Update your searchable activity's XML configuration file with information about your
3069066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * provider.</li>
3079066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li>In your searchable activities, capture any user-generated queries and record them
3089066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * for future searches by calling {@link android.provider.SearchRecentSuggestions#saveRecentQuery}.
3099066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * </li>
3109066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * </ul>
3119066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p>For complete implementation details, please refer to
3129066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * {@link android.content.SearchRecentSuggestionsProvider}.  The rest of the information in this
3139066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * section should not be necessary, as it refers to custom suggestions providers.
3149066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
3159066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p><b>Creating a Customized Suggestions Provider:</b>  In order to create more sophisticated
3169066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * suggestion providers, you'll need to take the following steps:
3179066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <ul>
3189066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li>Implement and test query search, as described in the previous sections.</li>
3199066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li>Decide how you wish to <i>receive</i> suggestions.  Just like queries that the user enters,
3209066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * suggestions will be delivered to your searchable activity as
3219066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * {@link android.content.Intent Intent} messages;  Unlike simple queries, you have quite a bit of
3229066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * flexibility in forming those intents.  A query search application will probably
3239066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * wish to continue receiving the {@link android.content.Intent#ACTION_SEARCH ACTION_SEARCH}
3249066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * {@link android.content.Intent Intent}, which will launch a query search using query text as
3259066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * provided by the suggestion.  A filter search application will probably wish to
3269066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * receive the {@link android.content.Intent#ACTION_VIEW ACTION_VIEW}
3279066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * {@link android.content.Intent Intent}, which will take the user directly to a selected entry.
3289066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Other interesting suggestions, including hybrids, are possible, and the suggestion provider
3299066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * can easily mix-and-match results to provide a richer set of suggestions for the user.  Finally,
3309066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * you'll need to update your searchable activity (or other activities) to receive the intents
3319066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * as you've defined them.</li>
3329066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li>Implement a Content Provider that provides suggestions.  If you already have one, and it
3339066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * has access to your suggestions data.  If not, you'll have to create one.
3349066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * You'll also provide information about your Content Provider in your
3359066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * package's <a href="{@docRoot}guide/topics/manifest/manifest-intro.html">manifest</a>.</li>
3369066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li>Update your searchable activity's XML configuration file.  There are two categories of
3379066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * information used for suggestions:
3389066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <ul><li>The first is (required) data that the search manager will
3399066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * use to format the queries which are sent to the Content Provider.</li>
3409066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li>The second is (optional) parameters to configure structure
3419066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * if intents generated by suggestions.</li></li>
3429066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * </ul>
3439066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * </ul>
3449066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
3459066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p><b>Configuring your Content Provider to Receive Suggestion Queries.</b>  The basic job of
3469066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * a search suggestions {@link android.content.ContentProvider Content Provider} is to provide
3479066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * "live" (while-you-type) conversion of the user's query text into a set of zero or more
3489066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * suggestions.  Each application is free to define the conversion, and as described above there are
3499066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * many possible solutions.  This section simply defines how to communicate with the suggestion
3509066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * provider.
3519066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
3529066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p>The Search Manager must first determine if your package provides suggestions.  This is done
3539066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * by examination of your searchable meta-data XML file.  The android:searchSuggestAuthority
3549066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * attribute, if provided, is the signal to obtain & display suggestions.
3559066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
3569066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p>Every query includes a Uri, and the Search Manager will format the Uri as shown:
3579066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p><pre class="prettyprint">
3589066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * content:// your.suggest.authority / your.suggest.path / SearchManager.SUGGEST_URI_PATH_QUERY</pre>
3599066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
3609066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p>Your Content Provider can receive the query text in one of two ways.
3619066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <ul>
3629066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li><b>Query provided as a selection argument.</b>  If you define the attribute value
3639066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * android:searchSuggestSelection and include a string, this string will be passed as the
3649066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <i>selection</i> parameter to your Content Provider's query function.  You must define a single
3659066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * selection argument, using the '?' character.  The user's query text will be passed to you
3669066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * as the first element of the selection arguments array.</li>
3679066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li><b>Query provided with Data Uri.</b>  If you <i>do not</i> define the attribute value
3689066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * android:searchSuggestSelection, then the Search Manager will append another "/" followed by
3699066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * the user's query to the query Uri.  The query will be encoding using Uri encoding rules - don't
3709066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * forget to decode it.  (See {@link android.net.Uri#getPathSegments} and
3719066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * {@link android.net.Uri#getLastPathSegment} for helpful utilities you can use here.)</li>
3729066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * </ul>
373b5041368524045b6714081d14ff3c6b22598aab1Karl Rosaen *
374b5041368524045b6714081d14ff3c6b22598aab1Karl Rosaen * <p><b>Providing access to Content Providers that require permissions.</b>  If your content
375b5041368524045b6714081d14ff3c6b22598aab1Karl Rosaen * provider declares an android:readPermission in your application's manifest, you must provide
376b5041368524045b6714081d14ff3c6b22598aab1Karl Rosaen * access to the search infrastructure to the search suggestion path by including a path-permission
377b5041368524045b6714081d14ff3c6b22598aab1Karl Rosaen * that grants android:readPermission access to "android.permission.GLOBAL_SEARCH".  Granting access
378b5041368524045b6714081d14ff3c6b22598aab1Karl Rosaen * explicitly to the search infrastructure ensures it will be able to access the search suggestions
379b5041368524045b6714081d14ff3c6b22598aab1Karl Rosaen * without needing to know ahead of time any other details of the permissions protecting your
380b5041368524045b6714081d14ff3c6b22598aab1Karl Rosaen * provider.  Content providers that require no permissions are already available to the search
381b5041368524045b6714081d14ff3c6b22598aab1Karl Rosaen * infrastructure.  Here is an example of a provider that protects access to it with permissions,
382b5041368524045b6714081d14ff3c6b22598aab1Karl Rosaen * and provides read access to the search infrastructure to the path that it expects to receive the
383b5041368524045b6714081d14ff3c6b22598aab1Karl Rosaen * suggestion query on:
384b5041368524045b6714081d14ff3c6b22598aab1Karl Rosaen * <pre class="prettyprint">
385b5041368524045b6714081d14ff3c6b22598aab1Karl Rosaen * &lt;provider android:name="MyProvider" android:authorities="myprovider"
386b5041368524045b6714081d14ff3c6b22598aab1Karl Rosaen *        android:readPermission="android.permission.READ_MY_DATA"
387b5041368524045b6714081d14ff3c6b22598aab1Karl Rosaen *        android:writePermission="android.permission.WRITE_MY_DATA"&gt;
388b5041368524045b6714081d14ff3c6b22598aab1Karl Rosaen *    &lt;path-permission android:path="/search_suggest_query"
389b5041368524045b6714081d14ff3c6b22598aab1Karl Rosaen *            android:readPermission="android.permission.GLOBAL_SEARCH" /&gt;
390b5041368524045b6714081d14ff3c6b22598aab1Karl Rosaen * &lt;/provider&gt;
391b5041368524045b6714081d14ff3c6b22598aab1Karl Rosaen * </pre>
392b5041368524045b6714081d14ff3c6b22598aab1Karl Rosaen *
3939066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p><b>Handling empty queries.</b>  Your application should handle the "empty query"
3949066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * (no user text entered) case properly, and generate useful suggestions in this case.  There are a
3959066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * number of ways to do this;  Two are outlined here:
3969066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <ul><li>For a simple filter search of local data, you could simply present the entire dataset,
3979066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * unfiltered.  (example: People)</li>
3989066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li>For a query search, you could simply present the most recent queries.  This allows the user
3999066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * to quickly repeat a recent search.</li></ul>
400b5041368524045b6714081d14ff3c6b22598aab1Karl Rosaen *
4019066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p><b>The Format of Individual Suggestions.</b>  Your suggestions are communicated back to the
4029066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Search Manager by way of a {@link android.database.Cursor Cursor}.  The Search Manager will
4039066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * usually pass a null Projection, which means that your provider can simply return all appropriate
4049066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * columns for each suggestion.  The columns currently defined are:
4059066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
4069066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
4079066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
4089066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     <thead>
4099066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     <tr><th>Column Name</th> <th>Description</th> <th>Required?</th></tr>
4109066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     </thead>
4119066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
4129066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     <tbody>
4139066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     <tr><th>{@link #SUGGEST_COLUMN_FORMAT}</th>
4149066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *         <td><i>Unused - can be null.</i></td>
4159066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *         <td align="center">No</td>
4169066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     </tr>
4179066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
4189066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     <tr><th>{@link #SUGGEST_COLUMN_TEXT_1}</th>
4199066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *         <td>This is the line of text that will be presented to the user as the suggestion.</td>
4209066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *         <td align="center">Yes</td>
4219066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     </tr>
4229066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
4239066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     <tr><th>{@link #SUGGEST_COLUMN_TEXT_2}</th>
4249066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *         <td>If your cursor includes this column, then all suggestions will be provided in a
4259066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             two-line format.  The data in this column will be displayed as a second, smaller
4269066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             line of text below the primary suggestion, or it can be null or empty to indicate no
4279066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             text in this row's suggestion.</td>
4289066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *         <td align="center">No</td>
4299066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     </tr>
4309066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
4319066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     <tr><th>{@link #SUGGEST_COLUMN_ICON_1}</th>
4329066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *         <td>If your cursor includes this column, then all suggestions will be provided in an
433875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen *             icons+text format.  This value should be a reference to the icon to
4349066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             draw on the left side, or it can be null or zero to indicate no icon in this row.
4359066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             </td>
436875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen *         <td align="center">No.</td>
4379066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     </tr>
4389066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
4399066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     <tr><th>{@link #SUGGEST_COLUMN_ICON_2}</th>
4409066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *         <td>If your cursor includes this column, then all suggestions will be provided in an
441875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen *             icons+text format.  This value should be a reference to the icon to
4429066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             draw on the right side, or it can be null or zero to indicate no icon in this row.
4439066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             </td>
444875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen *         <td align="center">No.</td>
4459066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     </tr>
4469066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
4479066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     <tr><th>{@link #SUGGEST_COLUMN_INTENT_ACTION}</th>
4489066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *         <td>If this column exists <i>and</i> this element exists at the given row, this is the
4499066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             action that will be used when forming the suggestion's intent.  If the element is
4509066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             not provided, the action will be taken from the android:searchSuggestIntentAction
4519066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             field in your XML metadata.  <i>At least one of these must be present for the
4529066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             suggestion to generate an intent.</i>  Note:  If your action is the same for all
4539066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             suggestions, it is more efficient to specify it using XML metadata and omit it from
4549066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             the cursor.</td>
4559066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *         <td align="center">No</td>
4569066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     </tr>
4579066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
4589066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     <tr><th>{@link #SUGGEST_COLUMN_INTENT_DATA}</th>
4599066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *         <td>If this column exists <i>and</i> this element exists at the given row, this is the
4609066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             data that will be used when forming the suggestion's intent.  If the element is not
4619066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             provided, the data will be taken from the android:searchSuggestIntentData field in
4629066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             your XML metadata.  If neither source is provided, the Intent's data field will be
4639066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             null.  Note:  If your data is the same for all suggestions, or can be described
4649066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             using a constant part and a specific ID, it is more efficient to specify it using
4659066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             XML metadata and omit it from the cursor.</td>
4669066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *         <td align="center">No</td>
4679066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     </tr>
4689066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
4699066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     <tr><th>{@link #SUGGEST_COLUMN_INTENT_DATA_ID}</th>
4709066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *         <td>If this column exists <i>and</i> this element exists at the given row, then "/" and
4719066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             this value will be appended to the data field in the Intent.  This should only be
4729066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             used if the data field has already been set to an appropriate base string.</td>
4739066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *         <td align="center">No</td>
4749066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     </tr>
4759066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
476b5041368524045b6714081d14ff3c6b22598aab1Karl Rosaen *     <tr><th>{@link #SUGGEST_COLUMN_INTENT_EXTRA_DATA}</th>
477b5041368524045b6714081d14ff3c6b22598aab1Karl Rosaen *         <td>If this column exists <i>and</i> this element exists at a given row, this is the
478b5041368524045b6714081d14ff3c6b22598aab1Karl Rosaen *             data that will be used when forming the suggestion's intent.  If not provided,
479b5041368524045b6714081d14ff3c6b22598aab1Karl Rosaen *             the Intent's extra data field will be null.  This column allows suggestions to
480b5041368524045b6714081d14ff3c6b22598aab1Karl Rosaen *             provide additional arbitrary data which will be included as an extra under the
481b5041368524045b6714081d14ff3c6b22598aab1Karl Rosaen *             key {@link #EXTRA_DATA_KEY}.</td>
482b5041368524045b6714081d14ff3c6b22598aab1Karl Rosaen *         <td align="center">No.</td>
483b5041368524045b6714081d14ff3c6b22598aab1Karl Rosaen *     </tr>
484b5041368524045b6714081d14ff3c6b22598aab1Karl Rosaen *
4859066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     <tr><th>{@link #SUGGEST_COLUMN_QUERY}</th>
4869066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *         <td>If this column exists <i>and</i> this element exists at the given row, this is the
4879066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             data that will be used when forming the suggestion's query.</td>
4889066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *         <td align="center">Required if suggestion's action is
4899066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             {@link android.content.Intent#ACTION_SEARCH ACTION_SEARCH}, optional otherwise.</td>
4909066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     </tr>
491b5041368524045b6714081d14ff3c6b22598aab1Karl Rosaen *
492590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *     <tr><th>{@link #SUGGEST_COLUMN_SHORTCUT_ID}</th>
493590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *         <td>This column is used to indicate whether a search suggestion should be stored as a
494590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *             shortcut, and whether it should be validated.  Shortcuts are usually formed when the
495590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *             user clicks a suggestion from Quick Search Box.  If missing, the result will be
496590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *             stored as a shortcut and never refreshed.  If set to
497590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *             {@link #SUGGEST_NEVER_MAKE_SHORTCUT}, the result will not be stored as a shortcut.
498590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *             Otherwise, the shortcut id will be used to check back for for an up to date
499590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *             suggestion using {@link #SUGGEST_URI_PATH_SHORTCUT}. Read more about shortcut
500590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *             refreshing in the section about
501590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *             <a href="#ExposingSearchSuggestionsToQuickSearchBox">exposing search suggestions to
502590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *             Quick Search Box</a>.</td>
503590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *         <td align="center">No.  Only applicable to sources included in Quick Search Box.</td>
504590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *     </tr>
505590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *
506590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *     <tr><th>{@link #SUGGEST_COLUMN_SPINNER_WHILE_REFRESHING}</th>
507590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *         <td>This column is used to specify that a spinner should be shown in lieu of an icon2
50805b775e0b7180e33df0303b9e132931f4895357cMike LeBeau *             while the shortcut of this suggestion is being refreshed in Quick Search Box.</td>
509590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *         <td align="center">No.  Only applicable to sources included in Quick Search Box.</td>
510590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *     </tr>
511590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *
5129066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     <tr><th><i>Other Columns</i></th>
5139066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *         <td>Finally, if you have defined any <a href="#ActionKeys">Action Keys</a> and you wish
5149066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             for them to have suggestion-specific definitions, you'll need to define one
5159066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             additional column per action key.  The action key will only trigger if the
5169066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             currently-selection suggestion has a non-empty string in the corresponding column.
5179066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             See the section on <a href="#ActionKeys">Action Keys</a> for additional details and
5189066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             implementation steps.</td>
5199066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *         <td align="center">No</td>
5209066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     </tr>
5219066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
5229066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     </tbody>
5239066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * </table>
5249066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
5259066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p>Clearly there are quite a few permutations of your suggestion data, but in the next section
5269066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * we'll look at a few simple combinations that you'll select from.
5279066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
5289066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p><b>The Format Of Intents Sent By Search Suggestions.</b>  Although there are many ways to
5299066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * configure these intents, this document will provide specific information on just a few of them.
5309066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <ul><li><b>Launch a query.</b>  In this model, each suggestion represents a query that your
5319066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * searchable activity can perform, and the {@link android.content.Intent Intent} will be formatted
5329066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * exactly like those sent when the user enters query text and clicks the "GO" button:
5339066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *   <ul>
5349066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *   <li><b>Action:</b> {@link android.content.Intent#ACTION_SEARCH ACTION_SEARCH} provided
5359066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *   using your XML metadata (android:searchSuggestIntentAction).</li>
5369066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *   <li><b>Data:</b> empty (not used).</li>
5379066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *   <li><b>Query:</b> query text supplied by the cursor.</li>
5389066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *   </ul>
5399066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * </li>
5409066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li><b>Go directly to a result, using a complete Data Uri.</b>  In this model, the user will be
5419066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * taken directly to a specific result.
5429066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *   <ul>
5439066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *   <li><b>Action:</b> {@link android.content.Intent#ACTION_VIEW ACTION_VIEW}</li>
5449066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *   <li><b>Data:</b> a complete Uri, supplied by the cursor, that identifies the desired data.</li>
5459066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *   <li><b>Query:</b> query text supplied with the suggestion (probably ignored)</li>
5469066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *   </ul>
5479066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * </li>
5489066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li><b>Go directly to a result, using a synthesized Data Uri.</b>  This has the same result
5499066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * as the previous suggestion, but provides the Data Uri in a different way.
5509066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *   <ul>
5519066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *   <li><b>Action:</b> {@link android.content.Intent#ACTION_VIEW ACTION_VIEW}</li>
5529066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *   <li><b>Data:</b> The search manager will assemble a Data Uri using the following elements:
5539066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *   a Uri fragment provided in your XML metadata (android:searchSuggestIntentData), followed by
5549066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *   a single "/", followed by the value found in the {@link #SUGGEST_COLUMN_INTENT_DATA_ID}
5559066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *   entry in your cursor.</li>
5569066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *   <li><b>Query:</b> query text supplied with the suggestion (probably ignored)</li>
5579066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *   </ul>
5589066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * </li>
5599066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * </ul>
5609066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p>This list is not meant to be exhaustive.  Applications should feel free to define other types
5619066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * of suggestions.  For example, you could reduce long lists of results to summaries, and use one
5629066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * of the above intents (or one of your own) with specially formatted Data Uri's to display more
5639066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * detailed results.  Or you could display textual shortcuts as suggestions, but launch a display
5649066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * in a more data-appropriate format such as media artwork.
5659066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
5669066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p><b>Suggestion Rewriting.</b>  If the user navigates through the suggestions list, the UI
5679066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * may temporarily rewrite the user's query with a query that matches the currently selected
5689066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * suggestion.  This enables the user to see what query is being suggested, and also allows the user
5699066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * to click or touch in the entry EditText element and make further edits to the query before
5709066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * dispatching it.  In order to perform this correctly, the Search UI needs to know exactly what
5719066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * text to rewrite the query with.
5729066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
5739066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p>For each suggestion, the following logic is used to select a new query string:
5749066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <ul><li>If the suggestion provides an explicit value in the {@link #SUGGEST_COLUMN_QUERY}
5759066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * column, this value will be used.</li>
5769066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li>If the metadata includes the queryRewriteFromData flag, and the suggestion provides an
5779066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * explicit value for the intent Data field, this Uri will be used.  Note that this should only be
5789066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * used with Uri's that are intended to be user-visible, such as HTTP.  Internal Uri schemes should
5799066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * not be used in this way.</li>
5809066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li>If the metadata includes the queryRewriteFromText flag, the text in
5819066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * {@link #SUGGEST_COLUMN_TEXT_1} will be used.  This should be used for suggestions in which no
5829066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * query text is provided and the SUGGEST_COLUMN_INTENT_DATA values are not suitable for user
5839066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * inspection and editing.</li></ul>
5849066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
585590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen * <a name="ExposingSearchSuggestionsToQuickSearchBox"></a>
586590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen * <h3>Exposing Search Suggestions to Quick Search Box</h3>
587590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *
58805b775e0b7180e33df0303b9e132931f4895357cMike LeBeau * <p>Once your application is set up to provide search suggestions, making them available to the
589590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen * globally accessable Quick Search Box is as easy as setting android:includeInGlobalSearch to
590590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen * "true" in your searchable metadata file.  Beyond that, here are some more details of how
591590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen * suggestions interact with Quick Search Box, and optional ways that you may customize suggestions
592590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen * for your application.
59305b775e0b7180e33df0303b9e132931f4895357cMike LeBeau *
59405b775e0b7180e33df0303b9e132931f4895357cMike LeBeau * <p><b>Important Note:</b>  By default, your application will not be enabled as a suggestion
59505b775e0b7180e33df0303b9e132931f4895357cMike LeBeau * provider (or "searchable item") in Quick Search Box. Once your app is installed, the user must
59605b775e0b7180e33df0303b9e132931f4895357cMike LeBeau * enable it as a "searchable item" in the Search settings in order to receive your app's
59705b775e0b7180e33df0303b9e132931f4895357cMike LeBeau * suggestions in Quick Search Box. You should consider how to message this to users of your app -
59805b775e0b7180e33df0303b9e132931f4895357cMike LeBeau * perhaps with a note to the user the first time they launch the app about how to enable search
59905b775e0b7180e33df0303b9e132931f4895357cMike LeBeau * suggestions. This gives your app a chance to be queried for suggestions as the user types into
60005b775e0b7180e33df0303b9e132931f4895357cMike LeBeau * Quick Search Box, though exactly how or if your suggestions will be surfaced is decided by Quick
60105b775e0b7180e33df0303b9e132931f4895357cMike LeBeau * Search Box.
602590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *
603590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen * <p><b>Source Ranking:</b>  Once your application's search results are made available to Quick
60405b775e0b7180e33df0303b9e132931f4895357cMike LeBeau * Search Box, how they surface to the user for a particular query will be determined as appropriate
60505b775e0b7180e33df0303b9e132931f4895357cMike LeBeau * by Quick Search Box ranking. This may depend on how many other apps have results for that query,
60605b775e0b7180e33df0303b9e132931f4895357cMike LeBeau * and how often the user has clicked on your results compared to the other apps - but there is no
60705b775e0b7180e33df0303b9e132931f4895357cMike LeBeau * guarantee about how ranking will occur, or whether your app's suggestions will show at all for
60805b775e0b7180e33df0303b9e132931f4895357cMike LeBeau * a given query.  In general, you can expect that providing quality results will increase the
60905b775e0b7180e33df0303b9e132931f4895357cMike LeBeau * likelihood that your app's suggestions are provided in a prominent position, and apps that
61005b775e0b7180e33df0303b9e132931f4895357cMike LeBeau * provide lower quality suggestions will be more likely to be ranked lower and/or not displayed.
611590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *
612590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen * <p><b>Search Settings:</b>  Each app that is available to Quick Search Box has an entry in the
613590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen * system settings where the user can enable or disable the inclusion of its results.  Below the
614590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen * name of the application, each application may provide a brief description of what kind of
615590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen * information will be made available via a search settings description string pointed to by the
61605b775e0b7180e33df0303b9e132931f4895357cMike LeBeau * android:searchSettingsDescription attribute in the searchable metadata. Note that the
61705b775e0b7180e33df0303b9e132931f4895357cMike LeBeau * user will need to visit this settings menu to enable search suggestions for your app before your
61805b775e0b7180e33df0303b9e132931f4895357cMike LeBeau * app will have a chance to provide search suggestions to Quick Search Box - see the section
61905b775e0b7180e33df0303b9e132931f4895357cMike LeBeau * called "Important Note" above.
620590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *
62105b775e0b7180e33df0303b9e132931f4895357cMike LeBeau * <p><b>Shortcuts:</b>  Suggestions that are clicked on by the user may be automatically made into
62205b775e0b7180e33df0303b9e132931f4895357cMike LeBeau * shortcuts, which are suggestions that have been copied from your provider in order to be quickly
62305b775e0b7180e33df0303b9e132931f4895357cMike LeBeau * displayed without the need to re-query the original sources. Shortcutted suggestions may be
62405b775e0b7180e33df0303b9e132931f4895357cMike LeBeau * displayed for the query that yielded the suggestion and for any prefixes of that query. You can
62505b775e0b7180e33df0303b9e132931f4895357cMike LeBeau * request how to have your app's suggestions made into shortcuts, and whether they should be
62605b775e0b7180e33df0303b9e132931f4895357cMike LeBeau * refreshed, using the {@link #SUGGEST_COLUMN_SHORTCUT_ID} column:
627590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen * <ul><li>Suggestions that do not include a shortcut id column will be made into shortcuts and
628590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen * never refreshed.  This makes sense for suggestions that refer to data that will never be changed
629590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen * or removed.</li>
630590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen * <li>Suggestions that include a shortcut id will be re-queried for a fresh version of the
631590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen * suggestion each time the shortcut is displayed.  The shortcut will be quickly displayed with
632590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen * whatever data was most recently available until the refresh query returns, after which the
633590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen * suggestion will be dynamically refreshed with the up to date information.  The shortcut refresh
634590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen * query will be sent to your suggestion provider with a uri of {@link #SUGGEST_URI_PATH_SHORTCUT}.
635590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen * The result should contain one suggestion using the same columns as the suggestion query, or be
636590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen * empty, indicating that the shortcut is no longer valid.  Shortcut ids make sense when referring
637590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen * to data that may change over time, such as a contact's presence status.  If a suggestion refers
638590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen * to data that could take longer to refresh, such as a network based refresh of a stock quote, you
639590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen * may include {@link #SUGGEST_COLUMN_SPINNER_WHILE_REFRESHING} to show a progress spinner for the
640590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen * right hand icon until the refresh is complete.</li>
641590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen * <li>Finally, to prevent a suggestion from being copied into a shortcut, you may provide a
642590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen * shortcut id with a value of {@link #SUGGEST_NEVER_MAKE_SHORTCUT}.</li></ul>
643590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *
64405b775e0b7180e33df0303b9e132931f4895357cMike LeBeau * Note that Quick Search Box will ultimately decide whether to shortcut your app's suggestions,
64505b775e0b7180e33df0303b9e132931f4895357cMike LeBeau * considering these values as a strong request from your application.
64605b775e0b7180e33df0303b9e132931f4895357cMike LeBeau *
6479066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <a name="ActionKeys"></a>
6489066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <h3>Action Keys</h3>
6499066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
6509066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p>Searchable activities may also wish to provide shortcuts based on the various action keys
6519066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * available on the device.  The most basic example of this is the contacts app, which enables the
6529066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * green "dial" key for quick access during searching.  Not all action keys are available on
6539066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * every device, and not all are allowed to be overriden in this way.  (For example, the "Home"
6549066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * key must always return to the home screen, with no exceptions.)
6559066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
6569066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p>In order to define action keys for your searchable application, you must do two things.
6579066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
6589066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <ul>
6599066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li>You'll add one or more <i>actionkey</i> elements to your searchable metadata configuration
6609066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * file.  Each element defines one of the keycodes you are interested in,
6619066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * defines the conditions under which they are sent, and provides details
6629066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * on how to communicate the action key event back to your searchable activity.</li>
6639066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li>In your broadcast receiver, if you wish, you can check for action keys by checking the
6649066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * extras field of the {@link android.content.Intent Intent}.</li>
6659066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * </ul>
6669066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
6679066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p><b>Updating metadata.</b>  For each keycode of interest, you must add an &lt;actionkey&gt;
6689066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * element.  Within this element you must define two or three attributes.  The first attribute,
6699066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * &lt;android:keycode&gt;, is required;  It is the key code of the action key event, as defined in
6709066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * {@link android.view.KeyEvent}.  The remaining two attributes define the value of the actionkey's
6719066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <i>message</i>, which will be passed to your searchable activity in the
6729066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * {@link android.content.Intent Intent} (see below for more details).  Although each of these
6739066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * attributes is optional, you must define one or both for the action key to have any effect.
6749066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * &lt;android:queryActionMsg&gt; provides the message that will be sent if the action key is
6759066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * pressed while the user is simply entering query text.  &lt;android:suggestActionMsgColumn&gt;
6769066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * is used when action keys are tied to specific suggestions.  This attribute provides the name
6779066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * of a <i>column</i> in your suggestion cursor;  The individual suggestion, in that column,
6789066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * provides the message.  (If the cell is empty or null, that suggestion will not work with that
6799066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * action key.)
6809066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p>See the <a href="#SearchabilityMetadata">Searchability Metadata</a> section for more details
6819066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * and examples.
6829066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
6839066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p><b>Receiving Action Keys</b>  Intents launched by action keys will be specially marked
6849066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * using a combination of values.  This enables your searchable application to examine the intent,
6859066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * if necessary, and perform special processing.  For example, clicking a suggested contact might
6869066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * simply display them;  Selecting a suggested contact and clicking the dial button might
6879066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * immediately call them.
6889066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
6899066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p>When a search {@link android.content.Intent Intent} is launched by an action key, two values
6909066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * will be added to the extras field.
6919066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <ul>
6929066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li>To examine the key code, use {@link android.content.Intent#getIntExtra
6939066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * getIntExtra(SearchManager.ACTION_KEY)}.</li>
6949066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li>To examine the message string, use {@link android.content.Intent#getStringExtra
6959066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * getStringExtra(SearchManager.ACTION_MSG)}</li>
6969066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * </ul>
6979066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
6989066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <a name="SearchabilityMetadata"></a>
6999066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <h3>Searchability Metadata</h3>
7009066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
7019066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p>Every activity that is searchable must provide a small amount of additional information
7029066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * in order to properly configure the search system.  This controls the way that your search
7039066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * is presented to the user, and controls for the various modalities described previously.
7049066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
7059066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p>If your application is not searchable,
7069066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * then you do not need to provide any search metadata, and you can skip the rest of this section.
7079066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * When this search metadata cannot be found, the search manager will assume that the activity
7089066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * does not implement search.  (Note: to implement web-based search, you will need to add
7099066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * the android.app.default_searchable metadata to your manifest, as shown below.)
7109066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
7119066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p>Values you supply in metadata apply only to each local searchable activity.  Each
7129066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * searchable activity can define a completely unique search experience relevant to its own
7139066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * capabilities and user experience requirements, and a single application can even define multiple
7149066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * searchable activities.
7159066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
7169066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p><b>Metadata for searchable activity.</b>  As with your search implementations described
7179066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * above, you must first identify which of your activities is searchable.  In the
7189066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <a href="{@docRoot}guide/topics/manifest/manifest-intro.html">manifest</a> entry for this activity, you must
7199066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * provide two elements:
7209066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <ul><li>An intent-filter specifying that you can receive and process the
7219066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * {@link android.content.Intent#ACTION_SEARCH ACTION_SEARCH} {@link android.content.Intent Intent}.
7229066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * </li>
7239066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li>A reference to a small XML file (typically called "searchable.xml") which contains the
7249066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * remaining configuration information for how your application implements search.</li></ul>
7259066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
7269066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p>Here is a snippet showing the necessary elements in the
7279066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <a href="{@docRoot}guide/topics/manifest/manifest-intro.html">manifest</a> entry for your searchable activity.
7289066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <pre class="prettyprint">
7299066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *        &lt;!-- Search Activity - searchable --&gt;
7309066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *        &lt;activity android:name="MySearchActivity"
7319066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *                  android:label="Search"
7329066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *                  android:launchMode="singleTop"&gt;
7339066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *            &lt;intent-filter&gt;
7349066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *                &lt;action android:name="android.intent.action.SEARCH" /&gt;
7359066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *                &lt;category android:name="android.intent.category.DEFAULT" /&gt;
7369066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *            &lt;/intent-filter&gt;
7379066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *            &lt;meta-data android:name="android.app.searchable"
7389066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *                       android:resource="@xml/searchable" /&gt;
7399066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *        &lt;/activity&gt;</pre>
7409066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
7419066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p>Next, you must provide the rest of the searchability configuration in
7429066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * the small XML file, stored in the ../xml/ folder in your build.  The XML file is a
7439066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * simple enumeration of the search configuration parameters for searching within this activity,
7449066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * application, or package.  Here is a sample XML file (named searchable.xml, for use with
7459066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * the above manifest) for a query-search activity.
7469066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
7479066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <pre class="prettyprint">
7489066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * &lt;searchable xmlns:android="http://schemas.android.com/apk/res/android"
7499066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     android:label="@string/search_label"
7509066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     android:hint="@string/search_hint" &gt;
7519066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * &lt;/searchable&gt;</pre>
7529066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
7539066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p>Note that all user-visible strings <i>must</i> be provided in the form of "@string"
7549066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * references.  Hard-coded strings, which cannot be localized, will not work properly in search
7559066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * metadata.
7569066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
7579066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p>Attributes you can set in search metadata:
7589066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
7599066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
7609066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     <thead>
7619066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     <tr><th>Attribute</th> <th>Description</th> <th>Required?</th></tr>
7629066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     </thead>
7639066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
7649066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     <tbody>
7659066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     <tr><th>android:label</th>
7669066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *         <td>This is the name for your application that will be presented to the user in a
7679066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             list of search targets, or in the search box as a label.</td>
7689066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *         <td align="center">Yes</td>
7699066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     </tr>
7709066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
7719066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     <tr><th>android:icon</th>
772d27b10837525f341eee7d46013e2177b0bad3c60Scott Main *         <td>If provided, this icon will be shown in place of the label above the search box.
773d27b10837525f341eee7d46013e2177b0bad3c60Scott Main *           This is a reference to a drawable (icon) resource. Note that the application icon
774d27b10837525f341eee7d46013e2177b0bad3c60Scott Main *           is also used as an icon to the left of the search box and you cannot modify this
775d27b10837525f341eee7d46013e2177b0bad3c60Scott Main *           behavior, so including the icon attribute is unecessary and this may be
776d27b10837525f341eee7d46013e2177b0bad3c60Scott Main *           deprecated in the future.</td>
7779066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *         <td align="center">No</td>
7789066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     </tr>
7799066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
7809066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     <tr><th>android:hint</th>
7819066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *         <td>This is the text to display in the search text field when no user text has been
7829066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             entered.</td>
7839066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *         <td align="center">No</td>
7849066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     </tr>
7859066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
7869066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     <tr><th>android:searchMode</th>
7879066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *         <td>If provided and non-zero, sets additional modes for control of the search
7889066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             presentation.  The following mode bits are defined:
7899066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             <table border="2" align="center" frame="hsides" rules="rows">
7909066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *                 <tbody>
7919066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *                 <tr><th>showSearchLabelAsBadge</th>
7929066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *                     <td>If set, this flag enables the display of the search target (label)
793d27b10837525f341eee7d46013e2177b0bad3c60Scott Main *                         above the search box.  If this flag and showSearchIconAsBadge
7949066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *                         (see below) are both not set, no badge will be shown.</td>
7959066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *                 </tr>
7969066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *                 <tr><th>showSearchIconAsBadge</th>
797d27b10837525f341eee7d46013e2177b0bad3c60Scott Main *                     <td>If set, this flag enables the display of the search target (icon)
798d27b10837525f341eee7d46013e2177b0bad3c60Scott Main *                         above the search box.  If this flag and showSearchLabelAsBadge
7999066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *                         (see above) are both not set, no badge will be shown.  If both flags
8009066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *                         are set, showSearchIconAsBadge has precedence and the icon will be
801d27b10837525f341eee7d46013e2177b0bad3c60Scott Main *                         shown. Because the application icon is now used to the left of the
802d27b10837525f341eee7d46013e2177b0bad3c60Scott Main *                         search box by default, using this search mode is no longer necessary
803d27b10837525f341eee7d46013e2177b0bad3c60Scott Main *                         and may be deprecated in the future.</td>
8049066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *                 </tr>
8059066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *                 <tr><th>queryRewriteFromData</th>
8069066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *                     <td>If set, this flag causes the suggestion column SUGGEST_COLUMN_INTENT_DATA
8079066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *                         to be considered as the text for suggestion query rewriting.  This should
8089066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *                         only be used when the values in SUGGEST_COLUMN_INTENT_DATA are suitable
8099066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *                         for user inspection and editing - typically, HTTP/HTTPS Uri's.</td>
8109066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *                 </tr>
8119066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *                 <tr><th>queryRewriteFromText</th>
8129066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *                     <td>If set, this flag causes the suggestion column SUGGEST_COLUMN_TEXT_1 to
8139066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *                         be considered as the text for suggestion query rewriting.  This should
8149066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *                         be used for suggestions in which no query text is provided and the
8159066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *                         SUGGEST_COLUMN_INTENT_DATA values are not suitable for user inspection
8169066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *                         and editing.</td>
8179066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *                 </tr>
8189066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *                 </tbody>
81905b775e0b7180e33df0303b9e132931f4895357cMike LeBeau *            </table>
82005b775e0b7180e33df0303b9e132931f4895357cMike LeBeau *            Note that the icon of your app will likely be shown alongside any badge you specify,
82105b775e0b7180e33df0303b9e132931f4895357cMike LeBeau *            to differentiate search in your app from Quick Search Box. The display of this icon
82205b775e0b7180e33df0303b9e132931f4895357cMike LeBeau *            is not under the app's control.
82305b775e0b7180e33df0303b9e132931f4895357cMike LeBeau *         </td>
82405b775e0b7180e33df0303b9e132931f4895357cMike LeBeau *
8259066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *         <td align="center">No</td>
8269066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     </tr>
8279066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
8289066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     <tr><th>android:inputType</th>
8299066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *         <td>If provided, supplies a hint about the type of search text the user will be
8309066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             entering.  For most searches, in which free form text is expected, this attribute
8319066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             need not be provided.  Suitable values for this attribute are described in the
8329066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             <a href="../R.attr.html#inputType">inputType</a> attribute.</td>
8339066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *         <td align="center">No</td>
8349066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     </tr>
8359066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     <tr><th>android:imeOptions</th>
8369066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *         <td>If provided, supplies additional options for the input method.
8379066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             For most searches, in which free form text is expected, this attribute
8389066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             need not be provided, and will default to "actionSearch".
8399066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             Suitable values for this attribute are described in the
8409066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             <a href="../R.attr.html#imeOptions">imeOptions</a> attribute.</td>
8419066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *         <td align="center">No</td>
8429066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     </tr>
8439066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
8449066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     </tbody>
8459066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * </table>
8469066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
8479066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p><b>Styleable Resources in your Metadata.</b>  It's possible to provide alternate strings
8489066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * for your searchable application, in order to provide localization and/or to better visual
8499066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * presentation on different device configurations.  Each searchable activity has a single XML
8509066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * metadata file, but any resource references can be replaced at runtime based on device
8519066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * configuration, language setting, and other system inputs.
8529066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
8539066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p>A concrete example is the "hint" text you supply using the android:searchHint attribute.
8549066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * In portrait mode you'll have less screen space and may need to provide a shorter string, but
8559066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * in landscape mode you can provide a longer, more descriptive hint.  To do this, you'll need to
8569066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * define two or more strings.xml files, in the following directories:
8579066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <ul><li>.../res/values-land/strings.xml</li>
8589066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li>.../res/values-port/strings.xml</li>
8599066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li>.../res/values/strings.xml</li></ul>
8609066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
8619066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p>For more complete documentation on this capability, see
8629066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <a href="{@docRoot}guide/topics/resources/resources-i18n.html#AlternateResources">Resources and
8639066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Internationalization: Alternate Resources</a>.
8649066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
8659066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p><b>Metadata for non-searchable activities.</b>  Activities which are part of a searchable
8669066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * application, but don't implement search itself, require a bit of "glue" in order to cause
8679066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * them to invoke search using your searchable activity as their primary context.  If this is not
8689066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * provided, then searches from these activities will use the system default search context.
8699066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
8709066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p>The simplest way to specify this is to add a <i>search reference</i> element to the
8719066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * application entry in the <a href="{@docRoot}guide/topics/manifest/manifest-intro.html">manifest</a> file.
8729066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * The value of this reference can be either of:
8739066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <ul><li>The name of your searchable activity.
8749066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * It is typically prefixed by '.' to indicate that it's in the same package.</li>
8759066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li>A "*" indicates that the system may select a default searchable activity, in which
8769066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * case it will typically select web-based search.</li>
8779066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * </ul>
8789066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
8799066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p>Here is a snippet showing the necessary addition to the manifest entry for your
8809066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * non-searchable activities.
8819066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <pre class="prettyprint">
8829066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *        &lt;application&gt;
8839066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *            &lt;meta-data android:name="android.app.default_searchable"
8849066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *                       android:value=".MySearchActivity" /&gt;
8859066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
8869066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *            &lt;!-- followed by activities, providers, etc... --&gt;
8879066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *        &lt;/application&gt;</pre>
8889066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
8899066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p>You can also specify android.app.default_searchable on a per-activity basis, by including
8909066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * the meta-data element (as shown above) in one or more activity sections.  If found, these will
8919066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * override the reference in the application section.  The only reason to configure your application
8929066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * this way would be if you wish to partition it into separate sections with different search
8939066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * behaviors;  Otherwise this configuration is not recommended.
8949066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
8954c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler * <p><b>Additional metadata for search suggestions.</b>  If you have defined a content provider
8969066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * to generate search suggestions, you'll need to publish it to the system, and you'll need to
8979066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * provide a bit of additional XML metadata in order to configure communications with it.
8989066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
8999066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p>First, in your <a href="{@docRoot}guide/topics/manifest/manifest-intro.html">manifest</a>, you'll add the
9009066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * following lines.
9019066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <pre class="prettyprint">
9029066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *        &lt;!-- Content provider for search suggestions --&gt;
9039066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *        &lt;provider android:name="YourSuggestionProviderClass"
9049066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *                android:authorities="your.suggestion.authority" /&gt;</pre>
9059066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
9069066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p>Next, you'll add a few lines to your XML metadata file, as shown:
9079066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <pre class="prettyprint">
9089066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     &lt;!-- Required attribute for any suggestions provider --&gt;
9099066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     android:searchSuggestAuthority="your.suggestion.authority"
9109066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
9119066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     &lt;!-- Optional attribute for configuring queries --&gt;
9129066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     android:searchSuggestSelection="field =?"
9139066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
9149066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     &lt;!-- Optional attributes for configuring intent construction --&gt;
9159066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     android:searchSuggestIntentAction="intent action string"
9169066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     android:searchSuggestIntentData="intent data Uri" /&gt;</pre>
9179066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
9189066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p>Elements of search metadata that support suggestions:
9199066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
9209066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
9219066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     <thead>
9229066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     <tr><th>Attribute</th> <th>Description</th> <th>Required?</th></tr>
9239066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     </thead>
9249066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
9259066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     <tbody>
9269066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     <tr><th>android:searchSuggestAuthority</th>
9279066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *         <td>This value must match the authority string provided in the <i>provider</i> section
9289066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             of your <a href="{@docRoot}guide/topics/manifest/manifest-intro.html">manifest</a>.</td>
9299066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *         <td align="center">Yes</td>
9309066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     </tr>
9319066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
9329066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     <tr><th>android:searchSuggestPath</th>
9339066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *         <td>If provided, this will be inserted in the suggestions query Uri, after the authority
9349066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             you have provide but before the standard suggestions path.  This is only required if
9359066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             you have a single content provider issuing different types of suggestions (e.g. for
9369066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             different data types) and you need a way to disambiguate the suggestions queries
9379066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             when they are received.</td>
9389066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *         <td align="center">No</td>
9399066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     </tr>
9409066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
9419066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     <tr><th>android:searchSuggestSelection</th>
9429066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *         <td>If provided, this value will be passed into your query function as the
9439066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             <i>selection</i> parameter.  Typically this will be a WHERE clause for your database,
9449066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             and will contain a single question mark, which represents the actual query string
9459066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             that has been typed by the user.  However, you can also use any non-null value
9469066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             to simply trigger the delivery of the query text (via selection arguments), and then
9479066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             use the query text in any way appropriate for your provider (ignoring the actual
9489066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             text of the selection parameter.)</td>
9499066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *         <td align="center">No</td>
9509066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     </tr>
9519066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
9529066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     <tr><th>android:searchSuggestIntentAction</th>
9539066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *         <td>If provided, and not overridden by the selected suggestion, this value will be
9549066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             placed in the action field of the {@link android.content.Intent Intent} when the
9559066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             user clicks a suggestion.</td>
9569066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *         <td align="center">No</td>
9579066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
9589066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     <tr><th>android:searchSuggestIntentData</th>
9599066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *         <td>If provided, and not overridden by the selected suggestion, this value will be
9609066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             placed in the data field of the {@link android.content.Intent Intent} when the user
9619066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             clicks a suggestion.</td>
9629066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *         <td align="center">No</td>
9639066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     </tr>
9649066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
9659066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     </tbody>
9669066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * </table>
967b5041368524045b6714081d14ff3c6b22598aab1Karl Rosaen *
968590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen * <p>Elements of search metadata that configure search suggestions being available to Quick Search
969590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen * Box:
970590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
971590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *
972590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *     <thead>
973590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *     <tr><th>Attribute</th> <th>Description</th> <th>Required?</th></tr>
974590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *     </thead>
975590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *
976590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *     <tr><th>android:includeInGlobalSearch</th>
977590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *         <td>If true, indicates the search suggestions provided by your application should be
978590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *             included in the globally accessible Quick Search Box.  The attributes below are only
979590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *             applicable if this is set to true.</td>
980590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *         <td align="center">Yes</td>
981590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *     </tr>
982590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *
983590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *     <tr><th>android:searchSettingsDescription</th>
984590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *         <td>If provided, provides a brief description of the search suggestions that are provided
985590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *             by your application to Quick Search Box, and will be displayed in the search settings
986590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *             entry for your application.</td>
987590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *         <td align="center">No</td>
988590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *     </tr>
989590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *
990590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *     <tr><th>android:queryAfterZeroResults</th>
991590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *         <td>Indicates whether a source should be invoked for supersets of queries it has
992590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *             returned zero results for in the past.  For example, if a source returned zero
993590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *             results for "bo", it would be ignored for "bob".  If set to false, this source
994590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *             will only be ignored for a single session; the next time the search dialog is
995590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *             invoked, all sources will be queried.  The default value is false.</td>
996590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *         <td align="center">No</td>
997590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *     </tr>
998590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *
999590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *     <tr><th>android:searchSuggestThreshold</th>
1000590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *         <td>Indicates the minimum number of characters needed to trigger a source from Quick
1001590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *             Search Box.  Only guarantees that a source will not be queried for anything shorter
1002590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *             than the threshold.  The default value is 0.</td>
1003590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *         <td align="center">No</td>
1004590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *     </tr>
1005590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *
1006590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *     </tbody>
1007590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen * </table>
1008590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen *
10094c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler * <p><b>Additional metadata for search action keys.</b>  For each action key that you would like to
10109066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * define, you'll need to add an additional element defining that key, and using the attributes
10119066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * discussed in <a href="#ActionKeys">Action Keys</a>.  A simple example is shown here:
10129066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
10139066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <pre class="prettyprint">&lt;actionkey
10149066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     android:keycode="KEYCODE_CALL"
10159066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     android:queryActionMsg="call"
10169066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     android:suggestActionMsg="call"
10179066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     android:suggestActionMsgColumn="call_column" /&gt;</pre>
10189066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
10199066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p>Elements of search metadata that support search action keys.  Note that although each of the
10209066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * action message elements are marked as <i>optional</i>, at least one must be present for the
10219066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * action key to have any effect.
10229066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
10239066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
10249066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
10259066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     <thead>
10269066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     <tr><th>Attribute</th> <th>Description</th> <th>Required?</th></tr>
10279066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     </thead>
10289066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
10299066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     <tbody>
10309066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     <tr><th>android:keycode</th>
10319066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *         <td>This attribute denotes the action key you wish to respond to.  Note that not
10329066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             all action keys are actually supported using this mechanism, as many of them are
10339066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             used for typing, navigation, or system functions.  This will be added to the
10349066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             {@link android.content.Intent#ACTION_SEARCH ACTION_SEARCH} intent that is passed to
10359066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             your searchable activity.  To examine the key code, use
10369066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             {@link android.content.Intent#getIntExtra getIntExtra(SearchManager.ACTION_KEY)}.
10379066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             <p>Note, in addition to the keycode, you must also provide one or more of the action
10389066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             specifier attributes.</td>
10399066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *         <td align="center">Yes</td>
10409066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     </tr>
10419066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
10429066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     <tr><th>android:queryActionMsg</th>
10439066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *         <td>If you wish to handle an action key during normal search query entry, you
10449066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *          must define an action string here.  This will be added to the
10459066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *          {@link android.content.Intent#ACTION_SEARCH ACTION_SEARCH} intent that is passed to your
10469066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *          searchable activity.  To examine the string, use
10479066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *          {@link android.content.Intent#getStringExtra
10489066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *          getStringExtra(SearchManager.ACTION_MSG)}.</td>
10499066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *         <td align="center">No</td>
10509066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     </tr>
10519066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
10529066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     <tr><th>android:suggestActionMsg</th>
10539066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *         <td>If you wish to handle an action key while a suggestion is being displayed <i>and
10549066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             selected</i>, there are two ways to handle this.  If <i>all</i> of your suggestions
10559066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             can handle the action key, you can simply define the action message using this
10569066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             attribute.  This will be added to the
10579066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             {@link android.content.Intent#ACTION_SEARCH ACTION_SEARCH} intent that is passed to
10589066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             your searchable activity.  To examine the string, use
10599066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             {@link android.content.Intent#getStringExtra
10609066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             getStringExtra(SearchManager.ACTION_MSG)}.</td>
10619066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *         <td align="center">No</td>
10629066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     </tr>
10639066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
10649066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     <tr><th>android:suggestActionMsgColumn</th>
10659066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *         <td>If you wish to handle an action key while a suggestion is being displayed <i>and
10669066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             selected</i>, but you do not wish to enable this action key for every suggestion,
10679066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             then you can use this attribute to control it on a suggestion-by-suggestion basis.
10689066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             First, you must define a column (and name it here) where your suggestions will
10699066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             include the action string.  Then, in your content provider, you must provide this
10709066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             column, and when desired, provide data in this column.
10719066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             The search manager will look at your suggestion cursor, using the string
10729066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             provided here in order to select a column, and will use that to select a string from
10739066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             the cursor.  That string will be added to the
10749066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             {@link android.content.Intent#ACTION_SEARCH ACTION_SEARCH} intent that is passed to
10759066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             your searchable activity.  To examine the string, use
10769066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             {@link android.content.Intent#getStringExtra
10779066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             getStringExtra(SearchManager.ACTION_MSG)}.  <i>If the data does not exist for the
10789066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *             selection suggestion, the action key will be ignored.</i></td>
10799066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *         <td align="center">No</td>
10809066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     </tr>
10819066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
10829066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     </tbody>
10839066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * </table>
10849066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
10854c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler * <p><b>Additional metadata for enabling voice search.</b>  To enable voice search for your
10864c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler * activity, you can add fields to the metadata that enable and configure voice search.  When
10874c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler * enabled (and available on the device), a voice search button will be displayed in the
10884c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler * Search UI.  Clicking this button will launch a voice search activity.  When the user has
10894c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler * finished speaking, the voice search phrase will be transcribed into text and presented to the
10904c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler * searchable activity as if it were a typed query.
10914c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *
10924c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler * <p>Elements of search metadata that support voice search:
10934c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
10944c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *
10954c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *     <thead>
10964c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *     <tr><th>Attribute</th> <th>Description</th> <th>Required?</th></tr>
10974c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *     </thead>
10984c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *
10994c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *     <tr><th>android:voiceSearchMode</th>
11004c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *         <td>If provided and non-zero, enables voice search.  (Voice search may not be
11014c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *             provided by the device, in which case these flags will have no effect.)  The
11024c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *             following mode bits are defined:
11034c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *             <table border="2" align="center" frame="hsides" rules="rows">
11044c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *                 <tbody>
11054c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *                 <tr><th>showVoiceSearchButton</th>
11064c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *                     <td>If set, display a voice search button.  This only takes effect if voice
11074c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *                         search is available on the device.  If set, then launchWebSearch or
11084c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *                         launchRecognizer must also be set.</td>
11094c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *                 </tr>
11104c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *                 <tr><th>launchWebSearch</th>
11114c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *                     <td>If set, the voice search button will take the user directly to a
11124c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *                         built-in voice web search activity.  Most applications will not use this
11134c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *                         flag, as it will take the user away from the activity in which search
11144c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *                         was invoked.</td>
11154c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *                 </tr>
11164c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *                 <tr><th>launchRecognizer</th>
11174c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *                     <td>If set, the voice search button will take the user directly to a
11184c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *                         built-in voice recording activity.  This activity will prompt the user
11194c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *                         to speak, transcribe the spoken text, and forward the resulting query
11204c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *                         text to the searchable activity, just as if the user had typed it into
11214c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *                         the search UI and clicked the search button.</td>
11224c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *                 </tr>
11234c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *                 </tbody>
11244c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *            </table></td>
11254c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *         <td align="center">No</td>
11264c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *     </tr>
11274c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *
11284c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *     <tr><th>android:voiceLanguageModel</th>
11294c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *         <td>If provided, this specifies the language model that should be used by the voice
11304c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *             recognition system.
11314c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *             See {@link android.speech.RecognizerIntent#EXTRA_LANGUAGE_MODEL}
11324c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *             for more information.  If not provided, the default value
11334c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *             {@link android.speech.RecognizerIntent#LANGUAGE_MODEL_FREE_FORM} will be used.</td>
11344c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *         <td align="center">No</td>
11354c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *     </tr>
11364c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *
11374c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *     <tr><th>android:voicePromptText</th>
11384c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *         <td>If provided, this specifies a prompt that will be displayed during voice input.
11394c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *             (If not provided, a default prompt will be displayed.)</td>
11404c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *         <td align="center">No</td>
11414c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *     </tr>
11424c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *
11434c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *     <tr><th>android:voiceLanguage</th>
11444c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *         <td>If provided, this specifies the spoken language to be expected.  This is only
11454c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *             needed if it is different from the current value of
11464c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *             {@link java.util.Locale#getDefault()}.
11474c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *             </td>
11484c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *         <td align="center">No</td>
11494c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *     </tr>
11504c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *
11514c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *     <tr><th>android:voiceMaxResults</th>
11524c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *         <td>If provided, enforces the maximum number of results to return, including the "best"
11534c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *             result which will always be provided as the SEARCH intent's primary query.  Must be
11544c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *             one or greater.  Use {@link android.speech.RecognizerIntent#EXTRA_RESULTS}
11554c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *             to get the results from the intent.  If not provided, the recognizer will choose
11564c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *             how many results to return.</td>
11574c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *         <td align="center">No</td>
11584c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *     </tr>
11594c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *
11604c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *     </tbody>
11614c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler * </table>
11624c156ec6ec9adcb407189ee57e0c205039b60148Andy Stadler *
11639066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <a name="PassingSearchContext"></a>
11649066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <h3>Passing Search Context</h3>
11659066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
11669066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p>In order to improve search experience, an application may wish to specify
11679066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * additional data along with the search, such as local history or context.  For
11689066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * example, a maps search would be improved by including the current location.
11699066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * In order to simplify the structure of your activities, this can be done using
11709066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * the search manager.
11719066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
11729066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p>Any data can be provided at the time the search is launched, as long as it
11739066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * can be stored in a {@link android.os.Bundle Bundle} object.
11749066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
11759066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p>To pass application data into the Search Manager, you'll need to override
11769066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * {@link android.app.Activity#onSearchRequested onSearchRequested} as follows:
11779066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
11789066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <pre class="prettyprint">
11799066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * &#64;Override
11809066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * public boolean onSearchRequested() {
11819066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     Bundle appData = new Bundle();
11829066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     appData.put...();
11839066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     appData.put...();
11849066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     startSearch(null, false, appData);
11859066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     return true;
11869066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * }</pre>
11879066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
11889066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p>To receive application data from the Search Manager, you'll extract it from
11899066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * the {@link android.content.Intent#ACTION_SEARCH ACTION_SEARCH}
11909066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * {@link android.content.Intent Intent} as follows:
11919066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
11929066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <pre class="prettyprint">
11939066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * final Bundle appData = queryIntent.getBundleExtra(SearchManager.APP_DATA);
11949066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * if (appData != null) {
11959066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     appData.get...();
11969066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *     appData.get...();
11979066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * }</pre>
11989066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
11999066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <a name="ProtectingUserPrivacy"></a>
12009066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <h3>Protecting User Privacy</h3>
12019066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
12029066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p>Many users consider their activities on the phone, including searches, to be private
12039066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * information.  Applications that implement search should take steps to protect users' privacy
12049066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * wherever possible.  This section covers two areas of concern, but you should consider your search
12059066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * design carefully and take any additional steps necessary.
12069066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
12079066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p><b>Don't send personal information to servers, and if you do, don't log it.</b>
12089066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * "Personal information" is information that can personally identify your users, such as name,
12099066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * email address or billing information, or other data which can be reasonably linked to such
12109066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * information.  If your application implements search with the assistance of a server, try to
12119066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * avoid sending personal information with your searches.  For example, if you are searching for
12129066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * businesses near a zip code, you don't need to send the user ID as well - just send the zip code
12139066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * to the server.  If you do need to send personal information, you should take steps to avoid
12149066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * logging it.  If you must log it, you should protect that data very carefully, and erase it as
12159066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * soon as possible.
12169066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
12179066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p><b>Provide the user with a way to clear their search history.</b>  The Search Manager helps
12189066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * your application provide context-specific suggestions.  Sometimes these suggestions are based
12199066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * on previous searches, or other actions taken by the user in an earlier session.  A user may not
12209066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * wish for previous searches to be revealed to other users, for instance if they share their phone
12219066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * with a friend.  If your application provides suggestions that can reveal previous activities,
12229066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * you should implement a "Clear History" menu, preference, or button.  If you are using
12239066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * {@link android.provider.SearchRecentSuggestions}, you can simply call its
12249066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * {@link android.provider.SearchRecentSuggestions#clearHistory() clearHistory()} method from
12259066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * your "Clear History" UI.  If you are implementing your own form of recent suggestions, you'll
12269066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * need to provide a similar a "clear history" API in your provider, and call it from your
12279066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * "Clear History" UI.
12289066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */
12299066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectpublic class SearchManager
12309066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        implements DialogInterface.OnDismissListener, DialogInterface.OnCancelListener
12319066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project{
12328d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert
12338d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert    private static final boolean DBG = false;
12348d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert    private static final String TAG = "SearchManager";
12358d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert
12369066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
12379066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * This is a shortcut definition for the default menu key to use for invoking search.
12389066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
12399066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * See Menu.Item.setAlphabeticShortcut() for more information.
12409066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
12419066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public final static char MENU_KEY = 's';
12429066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
12439066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
12449066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * This is a shortcut definition for the default menu key to use for invoking search.
12459066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
12469066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * See Menu.Item.setAlphabeticShortcut() for more information.
12479066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
12489066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public final static int MENU_KEYCODE = KeyEvent.KEYCODE_S;
12499066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
12509066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
12519066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Intent extra data key: Use this key with
12529066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * {@link android.content.Intent#getStringExtra
12539066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *  content.Intent.getStringExtra()}
12549066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * to obtain the query string from Intent.ACTION_SEARCH.
12559066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
12569066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public final static String QUERY = "query";
12579066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
12589066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
12595f80605a0b866f34c74955e190909bd6ab5d992eBjorn Bringert     * Intent extra data key: Use this key with
12605f80605a0b866f34c74955e190909bd6ab5d992eBjorn Bringert     * {@link android.content.Intent#getStringExtra
12615f80605a0b866f34c74955e190909bd6ab5d992eBjorn Bringert     *  content.Intent.getStringExtra()}
12625f80605a0b866f34c74955e190909bd6ab5d992eBjorn Bringert     * to obtain the query string typed in by the user.
12635f80605a0b866f34c74955e190909bd6ab5d992eBjorn Bringert     * This may be different from the value of {@link #QUERY}
12645f80605a0b866f34c74955e190909bd6ab5d992eBjorn Bringert     * if the intent is the result of selecting a suggestion.
12655f80605a0b866f34c74955e190909bd6ab5d992eBjorn Bringert     * In that case, {@link #QUERY} will contain the value of
12665f80605a0b866f34c74955e190909bd6ab5d992eBjorn Bringert     * {@link #SUGGEST_COLUMN_QUERY} for the suggestion, and
12675f80605a0b866f34c74955e190909bd6ab5d992eBjorn Bringert     * {@link #USER_QUERY} will contain the string typed by the
12685f80605a0b866f34c74955e190909bd6ab5d992eBjorn Bringert     * user.
12695f80605a0b866f34c74955e190909bd6ab5d992eBjorn Bringert     */
12705f80605a0b866f34c74955e190909bd6ab5d992eBjorn Bringert    public final static String USER_QUERY = "user_query";
12715f80605a0b866f34c74955e190909bd6ab5d992eBjorn Bringert
12725f80605a0b866f34c74955e190909bd6ab5d992eBjorn Bringert    /**
12739066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Intent extra data key: Use this key with Intent.ACTION_SEARCH and
12749066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * {@link android.content.Intent#getBundleExtra
12759066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *  content.Intent.getBundleExtra()}
12769066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * to obtain any additional app-specific data that was inserted by the
12779066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * activity that launched the search.
12789066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
12799066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public final static String APP_DATA = "app_data";
12809066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
12819066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
12829066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Intent app_data bundle key: Use this key with the bundle from
12839066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * {@link android.content.Intent#getBundleExtra
12849066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * content.Intent.getBundleExtra(APP_DATA)} to obtain the source identifier
12859066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * set by the activity that launched the search.
12869066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
12879066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @hide
12889066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
12899066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public final static String SOURCE = "source";
1290a058f02b591d971a829cb1e28d48a992e46ad85eKarl Rosaen
12919066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
1292be5b73c5926cbebd508d8323bdeaafa2e048a93cBjorn Bringert     * Intent extra data key: Use {@link android.content.Intent#getBundleExtra
1293be5b73c5926cbebd508d8323bdeaafa2e048a93cBjorn Bringert     * content.Intent.getBundleExtra(SEARCH_MODE)} to get the search mode used
1294be5b73c5926cbebd508d8323bdeaafa2e048a93cBjorn Bringert     * to launch the intent.
1295be5b73c5926cbebd508d8323bdeaafa2e048a93cBjorn Bringert     * The only current value for this is {@link #MODE_GLOBAL_SEARCH_SUGGESTION}.
1296be5b73c5926cbebd508d8323bdeaafa2e048a93cBjorn Bringert     *
1297be5b73c5926cbebd508d8323bdeaafa2e048a93cBjorn Bringert     * @hide
1298be5b73c5926cbebd508d8323bdeaafa2e048a93cBjorn Bringert     */
1299be5b73c5926cbebd508d8323bdeaafa2e048a93cBjorn Bringert    public final static String SEARCH_MODE = "search_mode";
1300be5b73c5926cbebd508d8323bdeaafa2e048a93cBjorn Bringert
1301be5b73c5926cbebd508d8323bdeaafa2e048a93cBjorn Bringert    /**
1302be5b73c5926cbebd508d8323bdeaafa2e048a93cBjorn Bringert     * Value for the {@link #SEARCH_MODE} key.
1303be5b73c5926cbebd508d8323bdeaafa2e048a93cBjorn Bringert     * This is used if the intent was launched by clicking a suggestion in global search
1304be5b73c5926cbebd508d8323bdeaafa2e048a93cBjorn Bringert     * mode (Quick Search Box).
1305be5b73c5926cbebd508d8323bdeaafa2e048a93cBjorn Bringert     *
1306be5b73c5926cbebd508d8323bdeaafa2e048a93cBjorn Bringert     * @hide
1307be5b73c5926cbebd508d8323bdeaafa2e048a93cBjorn Bringert     */
1308be5b73c5926cbebd508d8323bdeaafa2e048a93cBjorn Bringert    public static final String MODE_GLOBAL_SEARCH_SUGGESTION = "global_search_suggestion";
1309be5b73c5926cbebd508d8323bdeaafa2e048a93cBjorn Bringert
1310be5b73c5926cbebd508d8323bdeaafa2e048a93cBjorn Bringert    /**
13119066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Intent extra data key: Use this key with Intent.ACTION_SEARCH and
13129066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * {@link android.content.Intent#getIntExtra content.Intent.getIntExtra()}
13139066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * to obtain the keycode that the user used to trigger this query.  It will be zero if the
13149066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * user simply pressed the "GO" button on the search UI.  This is primarily used in conjunction
13159066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * with the keycode attribute in the actionkey element of your searchable.xml configuration
13169066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * file.
13179066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
13189066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public final static String ACTION_KEY = "action_key";
13199066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
13209066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
1321bf23fe062ab4321143717c21827d329e087cc72fSatish Sampath     * Intent component name key: This key will be used for the extra populated by the
1322bf23fe062ab4321143717c21827d329e087cc72fSatish Sampath     * {@link #SUGGEST_COLUMN_INTENT_COMPONENT_NAME} column.
1323bf23fe062ab4321143717c21827d329e087cc72fSatish Sampath     *
1324bf23fe062ab4321143717c21827d329e087cc72fSatish Sampath     * {@hide}
1325bf23fe062ab4321143717c21827d329e087cc72fSatish Sampath     */
1326bf23fe062ab4321143717c21827d329e087cc72fSatish Sampath    public final static String COMPONENT_NAME_KEY = "intent_component_name_key";
1327bf23fe062ab4321143717c21827d329e087cc72fSatish Sampath
1328bf23fe062ab4321143717c21827d329e087cc72fSatish Sampath    /**
1329875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     * Intent extra data key: This key will be used for the extra populated by the
1330875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     * {@link #SUGGEST_COLUMN_INTENT_EXTRA_DATA} column.
1331875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     */
1332875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen    public final static String EXTRA_DATA_KEY = "intent_extra_data_key";
1333a058f02b591d971a829cb1e28d48a992e46ad85eKarl Rosaen
1334a058f02b591d971a829cb1e28d48a992e46ad85eKarl Rosaen    /**
13351c54cf0903cd81467ca41ec6733c459e10b22763Karl Rosaen     * Defines the constants used in the communication between {@link android.app.SearchDialog} and
13361c54cf0903cd81467ca41ec6733c459e10b22763Karl Rosaen     * the global search provider via {@link Cursor#respond(android.os.Bundle)}.
1337a058f02b591d971a829cb1e28d48a992e46ad85eKarl Rosaen     *
13381c54cf0903cd81467ca41ec6733c459e10b22763Karl Rosaen     * @hide
1339a058f02b591d971a829cb1e28d48a992e46ad85eKarl Rosaen     */
13401c54cf0903cd81467ca41ec6733c459e10b22763Karl Rosaen    public static class DialogCursorProtocol {
1341a058f02b591d971a829cb1e28d48a992e46ad85eKarl Rosaen
13421c54cf0903cd81467ca41ec6733c459e10b22763Karl Rosaen        /**
13431c54cf0903cd81467ca41ec6733c459e10b22763Karl Rosaen         * The sent bundle will contain this integer key, with a value set to one of the events
13441c54cf0903cd81467ca41ec6733c459e10b22763Karl Rosaen         * below.
13451c54cf0903cd81467ca41ec6733c459e10b22763Karl Rosaen         */
13461c54cf0903cd81467ca41ec6733c459e10b22763Karl Rosaen        public final static String METHOD = "DialogCursorProtocol.method";
1347a058f02b591d971a829cb1e28d48a992e46ad85eKarl Rosaen
13481c54cf0903cd81467ca41ec6733c459e10b22763Karl Rosaen        /**
13491c54cf0903cd81467ca41ec6733c459e10b22763Karl Rosaen         * After data has been refreshed.
13501c54cf0903cd81467ca41ec6733c459e10b22763Karl Rosaen         */
13511c54cf0903cd81467ca41ec6733c459e10b22763Karl Rosaen        public final static int POST_REFRESH = 0;
13521c54cf0903cd81467ca41ec6733c459e10b22763Karl Rosaen        public final static String POST_REFRESH_RECEIVE_ISPENDING
13531c54cf0903cd81467ca41ec6733c459e10b22763Karl Rosaen                = "DialogCursorProtocol.POST_REFRESH.isPending";
13541c54cf0903cd81467ca41ec6733c459e10b22763Karl Rosaen        public final static String POST_REFRESH_RECEIVE_DISPLAY_NOTIFY
13551c54cf0903cd81467ca41ec6733c459e10b22763Karl Rosaen                = "DialogCursorProtocol.POST_REFRESH.displayNotify";
13561c54cf0903cd81467ca41ec6733c459e10b22763Karl Rosaen
13571c54cf0903cd81467ca41ec6733c459e10b22763Karl Rosaen        /**
13581c54cf0903cd81467ca41ec6733c459e10b22763Karl Rosaen         * When a position has been clicked.
13591c54cf0903cd81467ca41ec6733c459e10b22763Karl Rosaen         */
13601c54cf0903cd81467ca41ec6733c459e10b22763Karl Rosaen        public final static int CLICK = 2;
13611c54cf0903cd81467ca41ec6733c459e10b22763Karl Rosaen        public final static String CLICK_SEND_POSITION
13621c54cf0903cd81467ca41ec6733c459e10b22763Karl Rosaen                = "DialogCursorProtocol.CLICK.sendPosition";
13636ddaa3497ce7af2c303771365449501e2be52511Bjorn Bringert        public final static String CLICK_SEND_MAX_DISPLAY_POS
13646ddaa3497ce7af2c303771365449501e2be52511Bjorn Bringert                = "DialogCursorProtocol.CLICK.sendDisplayPosition";
13655417f09c141713c62be697fe10fe149d6d3d0eb4Bjorn Bringert        public final static String CLICK_SEND_ACTION_KEY
13665417f09c141713c62be697fe10fe149d6d3d0eb4Bjorn Bringert                = "DialogCursorProtocol.CLICK.sendActionKey";
13675417f09c141713c62be697fe10fe149d6d3d0eb4Bjorn Bringert        public final static String CLICK_SEND_ACTION_MSG
13685417f09c141713c62be697fe10fe149d6d3d0eb4Bjorn Bringert                = "DialogCursorProtocol.CLICK.sendActionMsg";
13691c54cf0903cd81467ca41ec6733c459e10b22763Karl Rosaen        public final static String CLICK_RECEIVE_SELECTED_POS
13701c54cf0903cd81467ca41ec6733c459e10b22763Karl Rosaen                = "DialogCursorProtocol.CLICK.receiveSelectedPosition";
13711c54cf0903cd81467ca41ec6733c459e10b22763Karl Rosaen
13721c54cf0903cd81467ca41ec6733c459e10b22763Karl Rosaen        /**
13731c54cf0903cd81467ca41ec6733c459e10b22763Karl Rosaen         * When the threshold received in {@link #POST_REFRESH_RECEIVE_DISPLAY_NOTIFY} is displayed.
13741c54cf0903cd81467ca41ec6733c459e10b22763Karl Rosaen         */
13751c54cf0903cd81467ca41ec6733c459e10b22763Karl Rosaen        public final static int THRESH_HIT = 3;
13762fcaf79a1856186e3823390c488e806c5955c8a6Bjorn Bringert
13772fcaf79a1856186e3823390c488e806c5955c8a6Bjorn Bringert        /**
13782fcaf79a1856186e3823390c488e806c5955c8a6Bjorn Bringert         * When a search is started without using a suggestion.
13792fcaf79a1856186e3823390c488e806c5955c8a6Bjorn Bringert         */
13802fcaf79a1856186e3823390c488e806c5955c8a6Bjorn Bringert        public final static int SEARCH = 4;
13812fcaf79a1856186e3823390c488e806c5955c8a6Bjorn Bringert        public final static String SEARCH_SEND_MAX_DISPLAY_POS
13822fcaf79a1856186e3823390c488e806c5955c8a6Bjorn Bringert                = "DialogCursorProtocol.SEARCH.sendDisplayPosition";
13832fcaf79a1856186e3823390c488e806c5955c8a6Bjorn Bringert        public final static String SEARCH_SEND_QUERY = "DialogCursorProtocol.SEARCH.query";
13841c54cf0903cd81467ca41ec6733c459e10b22763Karl Rosaen    }
1385a058f02b591d971a829cb1e28d48a992e46ad85eKarl Rosaen
1386875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen    /**
13879066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Intent extra data key: Use this key with Intent.ACTION_SEARCH and
13889066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * {@link android.content.Intent#getStringExtra content.Intent.getStringExtra()}
13899066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * to obtain the action message that was defined for a particular search action key and/or
13909066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * suggestion.  It will be null if the search was launched by typing "enter", touched the the
13919066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * "GO" button, or other means not involving any action key.
13929066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
13939066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public final static String ACTION_MSG = "action_msg";
13949066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
13959066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
13969066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Uri path for queried suggestions data.  This is the path that the search manager
13979066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * will use when querying your content provider for suggestions data based on user input
13989066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * (e.g. looking for partial matches).
13999066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Typically you'll use this with a URI matcher.
14009066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
14019066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public final static String SUGGEST_URI_PATH_QUERY = "search_suggest_query";
1402b2a5011578d4a64df2f39bdeeedfe9f37e7aecc4Karl Rosaen
1403b2a5011578d4a64df2f39bdeeedfe9f37e7aecc4Karl Rosaen    /**
1404b619c9198efa0108a692d352b0e7eaa534f922f3Karl Rosaen     * MIME type for suggestions data.  You'll use this in your suggestions content provider
1405b619c9198efa0108a692d352b0e7eaa534f922f3Karl Rosaen     * in the getType() function.
1406b619c9198efa0108a692d352b0e7eaa534f922f3Karl Rosaen     */
1407b619c9198efa0108a692d352b0e7eaa534f922f3Karl Rosaen    public final static String SUGGEST_MIME_TYPE =
1408b619c9198efa0108a692d352b0e7eaa534f922f3Karl Rosaen            "vnd.android.cursor.dir/vnd.android.search.suggest";
1409b619c9198efa0108a692d352b0e7eaa534f922f3Karl Rosaen
1410b619c9198efa0108a692d352b0e7eaa534f922f3Karl Rosaen    /**
1411b2a5011578d4a64df2f39bdeeedfe9f37e7aecc4Karl Rosaen     * Uri path for shortcut validation.  This is the path that the search manager will use when
1412b2a5011578d4a64df2f39bdeeedfe9f37e7aecc4Karl Rosaen     * querying your content provider to refresh a shortcutted suggestion result and to check if it
1413b2a5011578d4a64df2f39bdeeedfe9f37e7aecc4Karl Rosaen     * is still valid.  When asked, a source may return an up to date result, or no result.  No
1414b2a5011578d4a64df2f39bdeeedfe9f37e7aecc4Karl Rosaen     * result indicates the shortcut refers to a no longer valid sugggestion.
1415b2a5011578d4a64df2f39bdeeedfe9f37e7aecc4Karl Rosaen     *
1416b2a5011578d4a64df2f39bdeeedfe9f37e7aecc4Karl Rosaen     * @see #SUGGEST_COLUMN_SHORTCUT_ID
1417b2a5011578d4a64df2f39bdeeedfe9f37e7aecc4Karl Rosaen     */
1418b2a5011578d4a64df2f39bdeeedfe9f37e7aecc4Karl Rosaen    public final static String SUGGEST_URI_PATH_SHORTCUT = "search_suggest_shortcut";
14199066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
14209066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
1421b619c9198efa0108a692d352b0e7eaa534f922f3Karl Rosaen     * MIME type for shortcut validation.  You'll use this in your suggestions content provider
14229066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * in the getType() function.
14239066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
1424b619c9198efa0108a692d352b0e7eaa534f922f3Karl Rosaen    public final static String SHORTCUT_MIME_TYPE =
1425b619c9198efa0108a692d352b0e7eaa534f922f3Karl Rosaen            "vnd.android.cursor.item/vnd.android.search.suggest";
1426d4c98c4c450a95b67fe9746675984333b7653713Karl Rosaen
1427d4c98c4c450a95b67fe9746675984333b7653713Karl Rosaen
1428d4c98c4c450a95b67fe9746675984333b7653713Karl Rosaen    /**
1429d4c98c4c450a95b67fe9746675984333b7653713Karl Rosaen     * The authority of the provider to report clicks to when a click is detected after pivoting
1430d4c98c4c450a95b67fe9746675984333b7653713Karl Rosaen     * into a specific app's search from global search.
1431d4c98c4c450a95b67fe9746675984333b7653713Karl Rosaen     *
1432d4c98c4c450a95b67fe9746675984333b7653713Karl Rosaen     * In addition to the columns below, the suggestion columns are used to pass along the full
1433d4c98c4c450a95b67fe9746675984333b7653713Karl Rosaen     * suggestion so it can be shortcutted.
1434d4c98c4c450a95b67fe9746675984333b7653713Karl Rosaen     *
1435590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen     * @hide
1436d4c98c4c450a95b67fe9746675984333b7653713Karl Rosaen     */
1437d4c98c4c450a95b67fe9746675984333b7653713Karl Rosaen    public final static String SEARCH_CLICK_REPORT_AUTHORITY =
1438d4c98c4c450a95b67fe9746675984333b7653713Karl Rosaen            "com.android.globalsearch.stats";
1439d4c98c4c450a95b67fe9746675984333b7653713Karl Rosaen
1440d4c98c4c450a95b67fe9746675984333b7653713Karl Rosaen    /**
1441d4c98c4c450a95b67fe9746675984333b7653713Karl Rosaen     * The path the write goes to.
1442d4c98c4c450a95b67fe9746675984333b7653713Karl Rosaen     *
1443590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen     * @hide
1444d4c98c4c450a95b67fe9746675984333b7653713Karl Rosaen     */
1445d4c98c4c450a95b67fe9746675984333b7653713Karl Rosaen    public final static String SEARCH_CLICK_REPORT_URI_PATH = "click";
1446d4c98c4c450a95b67fe9746675984333b7653713Karl Rosaen
1447d4c98c4c450a95b67fe9746675984333b7653713Karl Rosaen    /**
1448d4c98c4c450a95b67fe9746675984333b7653713Karl Rosaen     * The column storing the query for the click.
1449d4c98c4c450a95b67fe9746675984333b7653713Karl Rosaen     *
1450590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen     * @hide
1451d4c98c4c450a95b67fe9746675984333b7653713Karl Rosaen     */
1452d4c98c4c450a95b67fe9746675984333b7653713Karl Rosaen    public final static String SEARCH_CLICK_REPORT_COLUMN_QUERY = "query";
1453d4c98c4c450a95b67fe9746675984333b7653713Karl Rosaen
1454d4c98c4c450a95b67fe9746675984333b7653713Karl Rosaen    /**
1455d4c98c4c450a95b67fe9746675984333b7653713Karl Rosaen     * The column storing the component name of the application that was pivoted into.
1456d4c98c4c450a95b67fe9746675984333b7653713Karl Rosaen     *
1457590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen     * @hide
1458d4c98c4c450a95b67fe9746675984333b7653713Karl Rosaen     */
1459d4c98c4c450a95b67fe9746675984333b7653713Karl Rosaen    public final static String SEARCH_CLICK_REPORT_COLUMN_COMPONENT = "component";
1460d4c98c4c450a95b67fe9746675984333b7653713Karl Rosaen
14619066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
14629066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Column name for suggestions cursor.  <i>Unused - can be null or column can be omitted.</i>
14639066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
14649066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public final static String SUGGEST_COLUMN_FORMAT = "suggest_format";
14659066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
14669066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Column name for suggestions cursor.  <i>Required.</i>  This is the primary line of text that
14679066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * will be presented to the user as the suggestion.
14689066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
14699066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public final static String SUGGEST_COLUMN_TEXT_1 = "suggest_text_1";
14709066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
14719066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Column name for suggestions cursor.  <i>Optional.</i>  If your cursor includes this column,
14729066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *  then all suggestions will be provided in a two-line format.  The second line of text is in
14739066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *  a much smaller appearance.
14749066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
14759066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public final static String SUGGEST_COLUMN_TEXT_2 = "suggest_text_2";
14769066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
14779066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Column name for suggestions cursor.  <i>Optional.</i>  If your cursor includes this column,
1478875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     *  then all suggestions will be provided in a format that includes space for two small icons,
14799066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *  one at the left and one at the right of each suggestion.  The data in the column must
1480875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     *  be a resource ID of a drawable, or a URI in one of the following formats:
1481875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     *
1482875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     * <ul>
1483875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     * <li>content ({@link android.content.ContentResolver#SCHEME_CONTENT})</li>
1484875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     * <li>android.resource ({@link android.content.ContentResolver#SCHEME_ANDROID_RESOURCE})</li>
1485875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     * <li>file ({@link android.content.ContentResolver#SCHEME_FILE})</li>
1486875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     * </ul>
1487875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     *
1488875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     * See {@link android.content.ContentResolver#openAssetFileDescriptor(Uri, String)}
1489875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     * for more information on these schemes.
14909066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
14919066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public final static String SUGGEST_COLUMN_ICON_1 = "suggest_icon_1";
14929066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
14939066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Column name for suggestions cursor.  <i>Optional.</i>  If your cursor includes this column,
1494875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     *  then all suggestions will be provided in a format that includes space for two small icons,
14959066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *  one at the left and one at the right of each suggestion.  The data in the column must
1496875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     *  be a resource ID of a drawable, or a URI in one of the following formats:
1497875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     *
1498875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     * <ul>
1499875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     * <li>content ({@link android.content.ContentResolver#SCHEME_CONTENT})</li>
1500875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     * <li>android.resource ({@link android.content.ContentResolver#SCHEME_ANDROID_RESOURCE})</li>
1501875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     * <li>file ({@link android.content.ContentResolver#SCHEME_FILE})</li>
1502875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     * </ul>
1503875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     *
1504875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     * See {@link android.content.ContentResolver#openAssetFileDescriptor(Uri, String)}
1505875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     * for more information on these schemes.
15069066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
15079066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public final static String SUGGEST_COLUMN_ICON_2 = "suggest_icon_2";
15089066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
15099066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Column name for suggestions cursor.  <i>Optional.</i>  If this column exists <i>and</i>
15109066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * this element exists at the given row, this is the action that will be used when
15119066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * forming the suggestion's intent.  If the element is not provided, the action will be taken
15129066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * from the android:searchSuggestIntentAction field in your XML metadata.  <i>At least one of
15139066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * these must be present for the suggestion to generate an intent.</i>  Note:  If your action is
15149066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * the same for all suggestions, it is more efficient to specify it using XML metadata and omit
15159066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * it from the cursor.
15169066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
15179066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public final static String SUGGEST_COLUMN_INTENT_ACTION = "suggest_intent_action";
15189066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
15199066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Column name for suggestions cursor.  <i>Optional.</i>  If this column exists <i>and</i>
15209066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * this element exists at the given row, this is the data that will be used when
15219066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * forming the suggestion's intent.  If the element is not provided, the data will be taken
15229066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * from the android:searchSuggestIntentData field in your XML metadata.  If neither source
15239066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * is provided, the Intent's data field will be null.  Note:  If your data is
15249066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * the same for all suggestions, or can be described using a constant part and a specific ID,
15259066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * it is more efficient to specify it using XML metadata and omit it from the cursor.
15269066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
15279066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public final static String SUGGEST_COLUMN_INTENT_DATA = "suggest_intent_data";
15289066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
1529bf23fe062ab4321143717c21827d329e087cc72fSatish Sampath     * Column name for suggestions cursor.  <i>Optional.</i>  If this column exists <i>and</i>
1530bf23fe062ab4321143717c21827d329e087cc72fSatish Sampath     * this element exists at the given row, this is the data that will be used when
1531bf23fe062ab4321143717c21827d329e087cc72fSatish Sampath     * forming the suggestion's intent. If not provided, the Intent's extra data field will be null.
1532bf23fe062ab4321143717c21827d329e087cc72fSatish Sampath     * This column allows suggestions to provide additional arbitrary data which will be included as
1533131234c6f134c586208ec94bfe4ae021b057cf66Mike LeBeau     * an extra under the key {@link #EXTRA_DATA_KEY}.
1534bf23fe062ab4321143717c21827d329e087cc72fSatish Sampath     */
1535bf23fe062ab4321143717c21827d329e087cc72fSatish Sampath    public final static String SUGGEST_COLUMN_INTENT_EXTRA_DATA = "suggest_intent_extra_data";
1536bf23fe062ab4321143717c21827d329e087cc72fSatish Sampath    /**
1537875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     * Column name for suggestions cursor.  <i>Optional.</i>  This column allows suggestions
1538875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     *  to provide additional arbitrary data which will be included as an extra under the key
1539bf23fe062ab4321143717c21827d329e087cc72fSatish Sampath     *  {@link #COMPONENT_NAME_KEY}. For use by the global search system only - if other providers
154021fd5f144a3e6919ff6b4e8a1a733c940d5dd6dfMike LeBeau     *  attempt to use this column, the value will be overwritten by global search.
1541a058f02b591d971a829cb1e28d48a992e46ad85eKarl Rosaen     *
1542590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen     * @hide
1543875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     */
1544bf23fe062ab4321143717c21827d329e087cc72fSatish Sampath    public final static String SUGGEST_COLUMN_INTENT_COMPONENT_NAME = "suggest_intent_component";
1545875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen    /**
15469066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Column name for suggestions cursor.  <i>Optional.</i>  If this column exists <i>and</i>
15479066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * this element exists at the given row, then "/" and this value will be appended to the data
15489066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * field in the Intent.  This should only be used if the data field has already been set to an
15499066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * appropriate base string.
15509066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
15519066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public final static String SUGGEST_COLUMN_INTENT_DATA_ID = "suggest_intent_data_id";
15529066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
15539066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Column name for suggestions cursor.  <i>Required if action is
15549066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * {@link android.content.Intent#ACTION_SEARCH ACTION_SEARCH}, optional otherwise.</i>  If this
15559066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * column exists <i>and</i> this element exists at the given row, this is the data that will be
15569066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * used when forming the suggestion's query.
15579066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
15589066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public final static String SUGGEST_COLUMN_QUERY = "suggest_intent_query";
15599066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
1560875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen    /**
1561b2a5011578d4a64df2f39bdeeedfe9f37e7aecc4Karl Rosaen     * Column name for suggestions cursor. <i>Optional.</i>  This column is used to indicate whether
1562b5041368524045b6714081d14ff3c6b22598aab1Karl Rosaen     * a search suggestion should be stored as a shortcut, and whether it should be refreshed.  If
1563b2a5011578d4a64df2f39bdeeedfe9f37e7aecc4Karl Rosaen     * missing, the result will be stored as a shortcut and never validated.  If set to
1564b2a5011578d4a64df2f39bdeeedfe9f37e7aecc4Karl Rosaen     * {@link #SUGGEST_NEVER_MAKE_SHORTCUT}, the result will not be stored as a shortcut.
1565b5041368524045b6714081d14ff3c6b22598aab1Karl Rosaen     * Otherwise, the shortcut id will be used to check back for an up to date suggestion using
1566b2a5011578d4a64df2f39bdeeedfe9f37e7aecc4Karl Rosaen     * {@link #SUGGEST_URI_PATH_SHORTCUT}.
1567b2a5011578d4a64df2f39bdeeedfe9f37e7aecc4Karl Rosaen     */
1568b2a5011578d4a64df2f39bdeeedfe9f37e7aecc4Karl Rosaen    public final static String SUGGEST_COLUMN_SHORTCUT_ID = "suggest_shortcut_id";
1569b2a5011578d4a64df2f39bdeeedfe9f37e7aecc4Karl Rosaen
1570b2a5011578d4a64df2f39bdeeedfe9f37e7aecc4Karl Rosaen    /**
15711c5fa0f31009502c539c65de99010b63cb617aacSatish Sampath     * Column name for suggestions cursor. <i>Optional.</i>  This column is used to specify the
15721c5fa0f31009502c539c65de99010b63cb617aacSatish Sampath     * cursor item's background color if it needs a non-default background color. A non-zero value
15731c5fa0f31009502c539c65de99010b63cb617aacSatish Sampath     * indicates a valid background color to override the default.
15741c5fa0f31009502c539c65de99010b63cb617aacSatish Sampath     *
1575590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen     * @hide For internal use, not part of the public API.
15761c5fa0f31009502c539c65de99010b63cb617aacSatish Sampath     */
15771c5fa0f31009502c539c65de99010b63cb617aacSatish Sampath    public final static String SUGGEST_COLUMN_BACKGROUND_COLOR = "suggest_background_color";
1578ce0959df5ca49cf8f726adddb65978da83e42544Mike LeBeau
1579ce0959df5ca49cf8f726adddb65978da83e42544Mike LeBeau    /**
1580ce0959df5ca49cf8f726adddb65978da83e42544Mike LeBeau     * Column name for suggestions cursor. <i>Optional.</i> This column is used to specify
1581ce0959df5ca49cf8f726adddb65978da83e42544Mike LeBeau     * that a spinner should be shown in lieu of an icon2 while the shortcut of this suggestion
1582ce0959df5ca49cf8f726adddb65978da83e42544Mike LeBeau     * is being refreshed.
1583ce0959df5ca49cf8f726adddb65978da83e42544Mike LeBeau     */
1584ce0959df5ca49cf8f726adddb65978da83e42544Mike LeBeau    public final static String SUGGEST_COLUMN_SPINNER_WHILE_REFRESHING =
1585ce0959df5ca49cf8f726adddb65978da83e42544Mike LeBeau            "suggest_spinner_while_refreshing";
15861c5fa0f31009502c539c65de99010b63cb617aacSatish Sampath
15871c5fa0f31009502c539c65de99010b63cb617aacSatish Sampath    /**
1588b2a5011578d4a64df2f39bdeeedfe9f37e7aecc4Karl Rosaen     * Column value for suggestion column {@link #SUGGEST_COLUMN_SHORTCUT_ID} when a suggestion
1589b2a5011578d4a64df2f39bdeeedfe9f37e7aecc4Karl Rosaen     * should not be stored as a shortcut in global search.
1590b2a5011578d4a64df2f39bdeeedfe9f37e7aecc4Karl Rosaen     */
1591b2a5011578d4a64df2f39bdeeedfe9f37e7aecc4Karl Rosaen    public final static String SUGGEST_NEVER_MAKE_SHORTCUT = "_-1";
1592b2a5011578d4a64df2f39bdeeedfe9f37e7aecc4Karl Rosaen
1593b2a5011578d4a64df2f39bdeeedfe9f37e7aecc4Karl Rosaen    /**
1594875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     * If a suggestion has this value in {@link #SUGGEST_COLUMN_INTENT_ACTION},
1595875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     * the search dialog will switch to a different suggestion source when the
1596875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     * suggestion is clicked.
1597875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     *
1598875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     * {@link #SUGGEST_COLUMN_INTENT_DATA} must contain
1599875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     * the flattened {@link ComponentName} of the activity which is to be searched.
1600875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     *
1601875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     * TODO: Should {@link #SUGGEST_COLUMN_INTENT_DATA} instead contain a URI in the format
1602875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     * used by {@link android.provider.Applications}?
1603875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     *
1604875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     * TODO: This intent should be protected by the same permission that we use
1605875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     * for replacing the global search provider.
1606875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     *
1607875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     * The query text field will be set to the value of {@link #SUGGEST_COLUMN_QUERY}.
1608875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     *
1609875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     * @hide Pending API council approval.
1610875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     */
1611875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen    public final static String INTENT_ACTION_CHANGE_SEARCH_SOURCE
1612875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen            = "android.search.action.CHANGE_SEARCH_SOURCE";
1613a058f02b591d971a829cb1e28d48a992e46ad85eKarl Rosaen
1614875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen    /**
161574708bbdf8d6f172b08343bdc578a20aa4b39148Bjorn Bringert     * Intent action for finding the global search activity.
161674708bbdf8d6f172b08343bdc578a20aa4b39148Bjorn Bringert     * The global search provider should handle this intent.
161774708bbdf8d6f172b08343bdc578a20aa4b39148Bjorn Bringert     *
161874708bbdf8d6f172b08343bdc578a20aa4b39148Bjorn Bringert     * @hide Pending API council approval.
161974708bbdf8d6f172b08343bdc578a20aa4b39148Bjorn Bringert     */
162074708bbdf8d6f172b08343bdc578a20aa4b39148Bjorn Bringert    public final static String INTENT_ACTION_GLOBAL_SEARCH
162174708bbdf8d6f172b08343bdc578a20aa4b39148Bjorn Bringert            = "android.search.action.GLOBAL_SEARCH";
162274708bbdf8d6f172b08343bdc578a20aa4b39148Bjorn Bringert
162374708bbdf8d6f172b08343bdc578a20aa4b39148Bjorn Bringert    /**
1624875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     * Intent action for starting the global search settings activity.
1625875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     * The global search provider should handle this intent.
1626875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     *
1627875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     * @hide Pending API council approval.
1628875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     */
1629875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen    public final static String INTENT_ACTION_SEARCH_SETTINGS
1630875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen            = "android.search.action.SEARCH_SETTINGS";
16313a27803b29dc739685e1e2465a0ca697e4b60d14Mike LeBeau
16323a27803b29dc739685e1e2465a0ca697e4b60d14Mike LeBeau    /**
16333a27803b29dc739685e1e2465a0ca697e4b60d14Mike LeBeau     * Intent action for starting a web search provider's settings activity.
16343a27803b29dc739685e1e2465a0ca697e4b60d14Mike LeBeau     * Web search providers should handle this intent if they have provider-specific
16353a27803b29dc739685e1e2465a0ca697e4b60d14Mike LeBeau     * settings to implement.
16363a27803b29dc739685e1e2465a0ca697e4b60d14Mike LeBeau     */
16373a27803b29dc739685e1e2465a0ca697e4b60d14Mike LeBeau    public final static String INTENT_ACTION_WEB_SEARCH_SETTINGS
16383a27803b29dc739685e1e2465a0ca697e4b60d14Mike LeBeau            = "android.search.action.WEB_SEARCH_SETTINGS";
1639a058f02b591d971a829cb1e28d48a992e46ad85eKarl Rosaen
1640a058f02b591d971a829cb1e28d48a992e46ad85eKarl Rosaen    /**
1641f9acde27486bcc6eea1092073f7b47c31749efd6Satish Sampath     * Intent action broadcasted to inform that the searchables list or default have changed.
1642f9acde27486bcc6eea1092073f7b47c31749efd6Satish Sampath     * Components should handle this intent if they cache any searchable data and wish to stay
1643f9acde27486bcc6eea1092073f7b47c31749efd6Satish Sampath     * up to date on changes.
1644f9acde27486bcc6eea1092073f7b47c31749efd6Satish Sampath     */
1645f9acde27486bcc6eea1092073f7b47c31749efd6Satish Sampath    public final static String INTENT_ACTION_SEARCHABLES_CHANGED
1646f9acde27486bcc6eea1092073f7b47c31749efd6Satish Sampath            = "android.search.action.SEARCHABLES_CHANGED";
1647d4fb7a0d90b16e360b7a7b64cb7a6fd94f084c27Mike LeBeau
1648d4fb7a0d90b16e360b7a7b64cb7a6fd94f084c27Mike LeBeau    /**
1649d4fb7a0d90b16e360b7a7b64cb7a6fd94f084c27Mike LeBeau     * Intent action broadcasted to inform that the search settings have changed in some way.
1650590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen     * Either searchables have been enabled or disabled, or a different web search provider
1651590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen     * has been chosen.
1652d4fb7a0d90b16e360b7a7b64cb7a6fd94f084c27Mike LeBeau     */
1653d4fb7a0d90b16e360b7a7b64cb7a6fd94f084c27Mike LeBeau    public final static String INTENT_ACTION_SEARCH_SETTINGS_CHANGED
1654d4fb7a0d90b16e360b7a7b64cb7a6fd94f084c27Mike LeBeau            = "android.search.action.SETTINGS_CHANGED";
1655f9acde27486bcc6eea1092073f7b47c31749efd6Satish Sampath
1656f9acde27486bcc6eea1092073f7b47c31749efd6Satish Sampath    /**
1657a058f02b591d971a829cb1e28d48a992e46ad85eKarl Rosaen     * If a suggestion has this value in {@link #SUGGEST_COLUMN_INTENT_ACTION},
1658a058f02b591d971a829cb1e28d48a992e46ad85eKarl Rosaen     * the search dialog will take no action.
1659a058f02b591d971a829cb1e28d48a992e46ad85eKarl Rosaen     *
1660590f63433ce786722d263c7e913a88d3101e5cbcKarl Rosaen     * @hide
1661a058f02b591d971a829cb1e28d48a992e46ad85eKarl Rosaen     */
1662a058f02b591d971a829cb1e28d48a992e46ad85eKarl Rosaen    public final static String INTENT_ACTION_NONE = "android.search.action.ZILCH";
1663875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen
1664875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen    /**
1665875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     * Reference to the shared system search service.
1666875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     */
16678d1538237847baf381787b881141f8c0478bef5bBjorn Bringert    private static ISearchManager mService;
16689066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
16699066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    private final Context mContext;
16708d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert
1671d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen    /**
1672d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen     * compact representation of the activity associated with this search manager so
1673d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen     * we can say who we are when starting search.  the search managerservice, in turn,
1674d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen     * uses this to properly handle the back stack.
1675d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen     */
1676b06ea706530e6d19eb2a1a9a7ae6c5dd77d80af0Dianne Hackborn    private int mIdent;
1677d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen
1678d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen    /**
1679d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen     * The package associated with this seach manager.
1680d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen     */
1681d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen    private String mAssociatedPackage;
1682b06ea706530e6d19eb2a1a9a7ae6c5dd77d80af0Dianne Hackborn
16838d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert    // package private since they are used by the inner class SearchManagerCallback
16848d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert    /* package */ final Handler mHandler;
16858d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert    /* package */ OnDismissListener mDismissListener = null;
16868d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert    /* package */ OnCancelListener mCancelListener = null;
16878d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert
16888d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert    private final SearchManagerCallback mSearchManagerCallback = new SearchManagerCallback();
16899066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
16909066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /*package*/ SearchManager(Context context, Handler handler)  {
16919066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        mContext = context;
16929066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        mHandler = handler;
16938d1538237847baf381787b881141f8c0478bef5bBjorn Bringert        mService = ISearchManager.Stub.asInterface(
16948d1538237847baf381787b881141f8c0478bef5bBjorn Bringert                ServiceManager.getService(Context.SEARCH_SERVICE));
16959066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
1696ec0a12cf199659a749ff1fe7b788626eddc095ebKarl Rosaen
1697ec0a12cf199659a749ff1fe7b788626eddc095ebKarl Rosaen    /*package*/ boolean hasIdent() {
1698ec0a12cf199659a749ff1fe7b788626eddc095ebKarl Rosaen        return mIdent != 0;
1699ec0a12cf199659a749ff1fe7b788626eddc095ebKarl Rosaen    }
17009066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
1701d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen    /*package*/ void setIdent(int ident, ComponentName component) {
1702b06ea706530e6d19eb2a1a9a7ae6c5dd77d80af0Dianne Hackborn        if (mIdent != 0) {
1703b06ea706530e6d19eb2a1a9a7ae6c5dd77d80af0Dianne Hackborn            throw new IllegalStateException("mIdent already set");
1704b06ea706530e6d19eb2a1a9a7ae6c5dd77d80af0Dianne Hackborn        }
1705d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen        if (component == null) {
1706d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen            throw new IllegalArgumentException("component must be non-null");
1707d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen        }
1708b06ea706530e6d19eb2a1a9a7ae6c5dd77d80af0Dianne Hackborn        mIdent = ident;
1709d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen        mAssociatedPackage = component.getPackageName();
1710b06ea706530e6d19eb2a1a9a7ae6c5dd77d80af0Dianne Hackborn    }
1711b06ea706530e6d19eb2a1a9a7ae6c5dd77d80af0Dianne Hackborn
17129066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
17139066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Launch search UI.
17149066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
17159066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * <p>The search manager will open a search widget in an overlapping
17169066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * window, and the underlying activity may be obscured.  The search
17179066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * entry state will remain in effect until one of the following events:
17189066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * <ul>
17199066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * <li>The user completes the search.  In most cases this will launch
17209066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * a search intent.</li>
17219066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * <li>The user uses the back, home, or other keys to exit the search.</li>
17229066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * <li>The application calls the {@link #stopSearch}
17239066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * method, which will hide the search window and return focus to the
17249066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * activity from which it was launched.</li>
17259066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
17269066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * <p>Most applications will <i>not</i> use this interface to invoke search.
17279066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * The primary method for invoking search is to call
17289066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * {@link android.app.Activity#onSearchRequested Activity.onSearchRequested()} or
17299066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * {@link android.app.Activity#startSearch Activity.startSearch()}.
17309066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
17319066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param initialQuery A search string can be pre-entered here, but this
17329066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * is typically null or empty.
17339066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param selectInitialQuery If true, the intial query will be preselected, which means that
17349066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * any further typing will replace it.  This is useful for cases where an entire pre-formed
17359066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * query is being inserted.  If false, the selection point will be placed at the end of the
17369066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * inserted query.  This is useful when the inserted query is text that the user entered,
17379066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * and the user would expect to be able to keep typing.  <i>This parameter is only meaningful
17389066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * if initialQuery is a non-empty string.</i>
17399066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param launchActivity The ComponentName of the activity that has launched this search.
17409066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param appSearchData An application can insert application-specific
17419066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * context here, in order to improve quality or specificity of its own
17429066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * searches.  This data will be returned with SEARCH intent(s).  Null if
17439066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * no extra data is required.
17449066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param globalSearch If false, this will only launch the search that has been specifically
17459066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * defined by the application (which is usually defined as a local search).  If no default
1746cfa419b754332e12f8cd45244c2f3bee9d6a74bbMike LeBeau     * search is defined in the current application or activity, global search will be launched.
17479066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * If true, this will always launch a platform-global (e.g. web-based) search instead.
17489066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
17499066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @see android.app.Activity#onSearchRequested
17509066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @see #stopSearch
17519066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
17529066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public void startSearch(String initialQuery,
17539066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project                            boolean selectInitialQuery,
17549066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project                            ComponentName launchActivity,
17559066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project                            Bundle appSearchData,
17569066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project                            boolean globalSearch) {
1757b06ea706530e6d19eb2a1a9a7ae6c5dd77d80af0Dianne Hackborn        if (mIdent == 0) throw new IllegalArgumentException(
1758b06ea706530e6d19eb2a1a9a7ae6c5dd77d80af0Dianne Hackborn                "Called from outside of an Activity context");
1759d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen        if (!globalSearch && !mAssociatedPackage.equals(launchActivity.getPackageName())) {
1760d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen            Log.w(TAG, "invoking app search on a different package " +
1761d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen                    "not associated with this search manager");
1762d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen        }
17638d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert        try {
17648d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert            // activate the search manager and start it up!
17658d1538237847baf381787b881141f8c0478bef5bBjorn Bringert            mService.startSearch(initialQuery, selectInitialQuery, launchActivity, appSearchData,
1766b06ea706530e6d19eb2a1a9a7ae6c5dd77d80af0Dianne Hackborn                    globalSearch, mSearchManagerCallback, mIdent);
17678d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert        } catch (RemoteException ex) {
1768d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen            Log.e(TAG, "startSearch() failed.", ex);
1769d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen        }
1770d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen    }
1771d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen
1772d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen    /**
1773d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen     * Similar to {@link #startSearch} but actually fires off the search query after invoking
1774d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen     * the search dialog.  Made available for testing purposes.
1775d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen     *
1776d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen     * @param query The query to trigger.  If empty, request will be ignored.
1777d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen     * @param launchActivity The ComponentName of the activity that has launched this search.
1778d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen     * @param appSearchData An application can insert application-specific
1779d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen     * context here, in order to improve quality or specificity of its own
1780d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen     * searches.  This data will be returned with SEARCH intent(s).  Null if
1781d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen     * no extra data is required.
1782d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen     * @param globalSearch If false, this will only launch the search that has been specifically
1783d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen     * defined by the application (which is usually defined as a local search).  If no default
1784d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen     * search is defined in the current application or activity, no search will be launched.
1785d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen     * If true, this will always launch a platform-global (e.g. web-based) search instead.
1786d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen     *
1787d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen     * @see #startSearch
1788d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen     */
1789d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen    public void triggerSearch(String query,
1790d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen                              ComponentName launchActivity,
1791d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen                              Bundle appSearchData,
1792d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen                              boolean globalSearch) {
1793d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen        if (mIdent == 0) throw new IllegalArgumentException(
1794d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen                "Called from outside of an Activity context");
1795d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen        if (!mAssociatedPackage.equals(launchActivity.getPackageName())) {
1796d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen            throw new IllegalArgumentException("invoking app search on a different package " +
1797d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen                    "not associated with this search manager");
1798d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen        }
1799d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen        if (query == null || TextUtils.getTrimmedLength(query) == 0) {
1800d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen            Log.w(TAG, "triggerSearch called with empty query, ignoring.");
1801d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen            return;
1802d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen        }
1803d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen        try {
1804d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen            mService.triggerSearch(query, launchActivity, appSearchData, mSearchManagerCallback,
1805d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen                    globalSearch, mIdent);
1806d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen        } catch (RemoteException ex) {
1807d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6krosaen            Log.e(TAG, "triggerSearch() failed.", ex);
18089066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        }
18099066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
18109066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
18119066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
18129066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Terminate search UI.
18139066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
18149066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * <p>Typically the user will terminate the search UI by launching a
18159066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * search or by canceling.  This function allows the underlying application
18169066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * or activity to cancel the search prematurely (for any reason).
18179066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
18189066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * <p>This function can be safely called at any time (even if no search is active.)
18199066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
18209066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @see #startSearch
18219066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
18228d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert    public void stopSearch() {
1823ea52d29bc46c306f3607d121aa1ad84f0e9eb473Karl Rosaen        if (DBG) debug("stopSearch()");
18248d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert        try {
18258d1538237847baf381787b881141f8c0478bef5bBjorn Bringert            mService.stopSearch();
18268d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert        } catch (RemoteException ex) {
18279066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        }
18289066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
18299066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
18309066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
18319066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Determine if the Search UI is currently displayed.
18329066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
18339066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * This is provided primarily for application test purposes.
18349066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
18359066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @return Returns true if the search UI is currently displayed.
18369066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
18379066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @hide
18389066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
18398d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert    public boolean isVisible() {
1840ea52d29bc46c306f3607d121aa1ad84f0e9eb473Karl Rosaen        if (DBG) debug("isVisible()");
1841ea52d29bc46c306f3607d121aa1ad84f0e9eb473Karl Rosaen        try {
1842ea52d29bc46c306f3607d121aa1ad84f0e9eb473Karl Rosaen            return mService.isVisible();
1843ea52d29bc46c306f3607d121aa1ad84f0e9eb473Karl Rosaen        } catch (RemoteException e) {
1844ea52d29bc46c306f3607d121aa1ad84f0e9eb473Karl Rosaen            Log.e(TAG, "isVisible() failed: " + e);
1845ea52d29bc46c306f3607d121aa1ad84f0e9eb473Karl Rosaen            return false;
1846ea52d29bc46c306f3607d121aa1ad84f0e9eb473Karl Rosaen        }
18479066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
18488d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert
18499066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
1850a058f02b591d971a829cb1e28d48a992e46ad85eKarl Rosaen     * See {@link SearchManager#setOnDismissListener} for configuring your activity to monitor
1851a058f02b591d971a829cb1e28d48a992e46ad85eKarl Rosaen     * search UI state.
18529066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
18539066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public interface OnDismissListener {
18549066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        /**
1855a058f02b591d971a829cb1e28d48a992e46ad85eKarl Rosaen         * This method will be called when the search UI is dismissed. To make use of it, you must
1856a058f02b591d971a829cb1e28d48a992e46ad85eKarl Rosaen         * implement this method in your activity, and call
1857a058f02b591d971a829cb1e28d48a992e46ad85eKarl Rosaen         * {@link SearchManager#setOnDismissListener} to register it.
18589066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project         */
18599066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        public void onDismiss();
18609066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
18619066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
18629066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
1863a058f02b591d971a829cb1e28d48a992e46ad85eKarl Rosaen     * See {@link SearchManager#setOnCancelListener} for configuring your activity to monitor
1864a058f02b591d971a829cb1e28d48a992e46ad85eKarl Rosaen     * search UI state.
18659066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
18669066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public interface OnCancelListener {
18679066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        /**
18689066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project         * This method will be called when the search UI is canceled. To make use if it, you must
1869a058f02b591d971a829cb1e28d48a992e46ad85eKarl Rosaen         * implement this method in your activity, and call
1870a058f02b591d971a829cb1e28d48a992e46ad85eKarl Rosaen         * {@link SearchManager#setOnCancelListener} to register it.
18719066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project         */
18729066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        public void onCancel();
18739066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
18749066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
18759066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
18769066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Set or clear the callback that will be invoked whenever the search UI is dismissed.
18779066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
18789066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param listener The {@link OnDismissListener} to use, or null.
18799066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
18809066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public void setOnDismissListener(final OnDismissListener listener) {
18819066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        mDismissListener = listener;
18829066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
18839066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
18849066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
18859066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Set or clear the callback that will be invoked whenever the search UI is canceled.
18869066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
18879066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param listener The {@link OnCancelListener} to use, or null.
18889066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
18898d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert    public void setOnCancelListener(OnCancelListener listener) {
18909066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        mCancelListener = listener;
18919066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
18928d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert
18938d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert    private class SearchManagerCallback extends ISearchManagerCallback.Stub {
18948d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert
18958d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert        private final Runnable mFireOnDismiss = new Runnable() {
18968d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert            public void run() {
18978d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert                if (DBG) debug("mFireOnDismiss");
18988d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert                if (mDismissListener != null) {
18998d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert                    mDismissListener.onDismiss();
19008d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert                }
19018d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert            }
19028d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert        };
19038d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert
19048d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert        private final Runnable mFireOnCancel = new Runnable() {
19058d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert            public void run() {
19068d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert                if (DBG) debug("mFireOnCancel");
19078d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert                if (mCancelListener != null) {
19088d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert                    mCancelListener.onCancel();
19098d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert                }
19109066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            }
19118d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert        };
19128d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert
19138d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert        public void onDismiss() {
19148d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert            if (DBG) debug("onDismiss()");
19158d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert            mHandler.post(mFireOnDismiss);
19168d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert        }
19178d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert
19188d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert        public void onCancel() {
19198d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert            if (DBG) debug("onCancel()");
19208d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert            mHandler.post(mFireOnCancel);
19219066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        }
19228d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert
19238d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert    }
19248d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert
19250e01ea41b215941128a4ea8dee454e6b35a4e798Bjorn Bringert    /**
19260e01ea41b215941128a4ea8dee454e6b35a4e798Bjorn Bringert     * @deprecated This method is an obsolete internal implementation detail. Do not use.
19270e01ea41b215941128a4ea8dee454e6b35a4e798Bjorn Bringert     */
19284a51c20ce607c74914f90fd897f04080121ac13bDianne Hackborn    @Deprecated
19298d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert    public void onCancel(DialogInterface dialog) {
19308d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert        throw new UnsupportedOperationException();
19318d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert    }
19320e01ea41b215941128a4ea8dee454e6b35a4e798Bjorn Bringert
19330e01ea41b215941128a4ea8dee454e6b35a4e798Bjorn Bringert    /**
19340e01ea41b215941128a4ea8dee454e6b35a4e798Bjorn Bringert     * @deprecated This method is an obsolete internal implementation detail. Do not use.
19350e01ea41b215941128a4ea8dee454e6b35a4e798Bjorn Bringert     */
19364a51c20ce607c74914f90fd897f04080121ac13bDianne Hackborn    @Deprecated
19378d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert    public void onDismiss(DialogInterface dialog) {
19388d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert        throw new UnsupportedOperationException();
19399066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
19409066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
19419066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
1942875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     * Gets information about a searchable activity. This method is static so that it can
1943875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     * be used from non-Activity contexts.
1944875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     *
1945875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     * @param componentName The activity to get searchable information for.
1946875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     * @param globalSearch If <code>false</code>, return information about the given activity.
1947875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     *        If <code>true</code>, return information about the global search activity.
1948875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     * @return Searchable information, or <code>null</code> if the activity is not searchable.
1949875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     *
1950875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     * @hide because SearchableInfo is not part of the API.
1951875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     */
19528d1538237847baf381787b881141f8c0478bef5bBjorn Bringert    public SearchableInfo getSearchableInfo(ComponentName componentName,
1953875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen            boolean globalSearch) {
1954875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen        try {
19558d1538237847baf381787b881141f8c0478bef5bBjorn Bringert            return mService.getSearchableInfo(componentName, globalSearch);
19568d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert        } catch (RemoteException ex) {
19578d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert            Log.e(TAG, "getSearchableInfo() failed: " + ex);
1958875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen            return null;
1959875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen        }
1960875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen    }
1961875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen
1962875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen    /**
1963875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     * Checks whether the given searchable is the default searchable.
1964875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     *
1965875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     * @hide because SearchableInfo is not part of the API.
1966875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen     */
19678d1538237847baf381787b881141f8c0478bef5bBjorn Bringert    public boolean isDefaultSearchable(SearchableInfo searchable) {
19688d1538237847baf381787b881141f8c0478bef5bBjorn Bringert        SearchableInfo defaultSearchable = getSearchableInfo(null, true);
1969875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen        return defaultSearchable != null
1970a92041306e4d73baa10fb711fb905b9590f06b26Bjorn Bringert                && defaultSearchable.getSearchActivity().equals(searchable.getSearchActivity());
1971875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen    }
19728d1538237847baf381787b881141f8c0478bef5bBjorn Bringert
1973875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen    /**
197497325db8565ad503b86d9a0f602b2d001b5cee13Bjorn Bringert     * Gets a cursor with search suggestions.
197597325db8565ad503b86d9a0f602b2d001b5cee13Bjorn Bringert     *
197697325db8565ad503b86d9a0f602b2d001b5cee13Bjorn Bringert     * @param searchable Information about how to get the suggestions.
197797325db8565ad503b86d9a0f602b2d001b5cee13Bjorn Bringert     * @param query The search text entered (so far).
197897325db8565ad503b86d9a0f602b2d001b5cee13Bjorn Bringert     * @return a cursor with suggestions, or <code>null</null> the suggestion query failed.
197997325db8565ad503b86d9a0f602b2d001b5cee13Bjorn Bringert     *
198097325db8565ad503b86d9a0f602b2d001b5cee13Bjorn Bringert     * @hide because SearchableInfo is not part of the API.
198197325db8565ad503b86d9a0f602b2d001b5cee13Bjorn Bringert     */
198297325db8565ad503b86d9a0f602b2d001b5cee13Bjorn Bringert    public Cursor getSuggestions(SearchableInfo searchable, String query) {
1983875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen        if (searchable == null) {
1984875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen            return null;
1985875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen        }
1986875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen
1987875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen        String authority = searchable.getSuggestAuthority();
1988875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen        if (authority == null) {
1989875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen            return null;
1990875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen        }
1991875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen
1992875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen        Uri.Builder uriBuilder = new Uri.Builder()
1993875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen                .scheme(ContentResolver.SCHEME_CONTENT)
1994875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen                .authority(authority);
1995875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen
1996875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen        // if content path provided, insert it now
1997875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen        final String contentPath = searchable.getSuggestPath();
1998875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen        if (contentPath != null) {
1999875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen            uriBuilder.appendEncodedPath(contentPath);
2000875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen        }
2001875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen
2002875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen        // append standard suggestion query path
2003875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen        uriBuilder.appendPath(SearchManager.SUGGEST_URI_PATH_QUERY);
2004875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen
2005875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen        // get the query selection, may be null
2006875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen        String selection = searchable.getSuggestSelection();
2007875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen        // inject query, either as selection args or inline
2008875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen        String[] selArgs = null;
2009875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen        if (selection != null) {    // use selection if provided
2010875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen            selArgs = new String[] { query };
2011875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen        } else {                    // no selection, use REST pattern
2012875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen            uriBuilder.appendPath(query);
2013875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen        }
2014875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen
2015875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen        Uri uri = uriBuilder
2016875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen                .query("")     // TODO: Remove, workaround for a bug in Uri.writeToParcel()
2017875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen                .fragment("")  // TODO: Remove, workaround for a bug in Uri.writeToParcel()
2018875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen                .build();
2019875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen
2020875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen        // finally, make the query
20218d1538237847baf381787b881141f8c0478bef5bBjorn Bringert        return mContext.getContentResolver().query(uri, null, selection, selArgs, null);
2022875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen    }
2023875d50a4b9294b2be33cff6493cae7acd1d07ea7Karl Rosaen
20246d72e029cb6e5a9cf26aa3314c3dca83614fc91bBjorn Bringert    /**
20256d72e029cb6e5a9cf26aa3314c3dca83614fc91bBjorn Bringert     * Returns a list of the searchable activities that can be included in global search.
20266d72e029cb6e5a9cf26aa3314c3dca83614fc91bBjorn Bringert     *
20276d72e029cb6e5a9cf26aa3314c3dca83614fc91bBjorn Bringert     * @return a list containing searchable information for all searchable activities
20286d72e029cb6e5a9cf26aa3314c3dca83614fc91bBjorn Bringert     *         that have the <code>exported</code> attribute set in their searchable
20296d72e029cb6e5a9cf26aa3314c3dca83614fc91bBjorn Bringert     *         meta-data.
20306d72e029cb6e5a9cf26aa3314c3dca83614fc91bBjorn Bringert     *
20316d72e029cb6e5a9cf26aa3314c3dca83614fc91bBjorn Bringert     * @hide because SearchableInfo is not part of the API.
20326d72e029cb6e5a9cf26aa3314c3dca83614fc91bBjorn Bringert     */
20338d1538237847baf381787b881141f8c0478bef5bBjorn Bringert    public List<SearchableInfo> getSearchablesInGlobalSearch() {
20346d72e029cb6e5a9cf26aa3314c3dca83614fc91bBjorn Bringert        try {
20358d1538237847baf381787b881141f8c0478bef5bBjorn Bringert            return mService.getSearchablesInGlobalSearch();
20366d72e029cb6e5a9cf26aa3314c3dca83614fc91bBjorn Bringert        } catch (RemoteException e) {
20378d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert            Log.e(TAG, "getSearchablesInGlobalSearch() failed: " + e);
20386d72e029cb6e5a9cf26aa3314c3dca83614fc91bBjorn Bringert            return null;
20396d72e029cb6e5a9cf26aa3314c3dca83614fc91bBjorn Bringert        }
20406d72e029cb6e5a9cf26aa3314c3dca83614fc91bBjorn Bringert    }
2041f9acde27486bcc6eea1092073f7b47c31749efd6Satish Sampath
2042f9acde27486bcc6eea1092073f7b47c31749efd6Satish Sampath    /**
2043f9acde27486bcc6eea1092073f7b47c31749efd6Satish Sampath     * Returns a list of the searchable activities that handle web searches.
2044f9acde27486bcc6eea1092073f7b47c31749efd6Satish Sampath     *
20458d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert     * @return a list of all searchable activities that handle
20468d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert     *         {@link android.content.Intent#ACTION_WEB_SEARCH}.
2047f9acde27486bcc6eea1092073f7b47c31749efd6Satish Sampath     *
2048f9acde27486bcc6eea1092073f7b47c31749efd6Satish Sampath     * @hide because SearchableInfo is not part of the API.
2049f9acde27486bcc6eea1092073f7b47c31749efd6Satish Sampath     */
20508d1538237847baf381787b881141f8c0478bef5bBjorn Bringert    public List<SearchableInfo> getSearchablesForWebSearch() {
2051f9acde27486bcc6eea1092073f7b47c31749efd6Satish Sampath        try {
20528d1538237847baf381787b881141f8c0478bef5bBjorn Bringert            return mService.getSearchablesForWebSearch();
2053f9acde27486bcc6eea1092073f7b47c31749efd6Satish Sampath        } catch (RemoteException e) {
20548d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert            Log.e(TAG, "getSearchablesForWebSearch() failed: " + e);
2055f9acde27486bcc6eea1092073f7b47c31749efd6Satish Sampath            return null;
2056f9acde27486bcc6eea1092073f7b47c31749efd6Satish Sampath        }
2057f9acde27486bcc6eea1092073f7b47c31749efd6Satish Sampath    }
2058f9acde27486bcc6eea1092073f7b47c31749efd6Satish Sampath
2059f9acde27486bcc6eea1092073f7b47c31749efd6Satish Sampath    /**
2060f9acde27486bcc6eea1092073f7b47c31749efd6Satish Sampath     * Returns the default searchable activity for web searches.
2061f9acde27486bcc6eea1092073f7b47c31749efd6Satish Sampath     *
2062f9acde27486bcc6eea1092073f7b47c31749efd6Satish Sampath     * @return searchable information for the activity handling web searches by default.
2063f9acde27486bcc6eea1092073f7b47c31749efd6Satish Sampath     *
2064f9acde27486bcc6eea1092073f7b47c31749efd6Satish Sampath     * @hide because SearchableInfo is not part of the API.
2065f9acde27486bcc6eea1092073f7b47c31749efd6Satish Sampath     */
20668d1538237847baf381787b881141f8c0478bef5bBjorn Bringert    public SearchableInfo getDefaultSearchableForWebSearch() {
2067f9acde27486bcc6eea1092073f7b47c31749efd6Satish Sampath        try {
20688d1538237847baf381787b881141f8c0478bef5bBjorn Bringert            return mService.getDefaultSearchableForWebSearch();
2069f9acde27486bcc6eea1092073f7b47c31749efd6Satish Sampath        } catch (RemoteException e) {
20708d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert            Log.e(TAG, "getDefaultSearchableForWebSearch() failed: " + e);
2071f9acde27486bcc6eea1092073f7b47c31749efd6Satish Sampath            return null;
2072f9acde27486bcc6eea1092073f7b47c31749efd6Satish Sampath        }
2073f9acde27486bcc6eea1092073f7b47c31749efd6Satish Sampath    }
2074f9acde27486bcc6eea1092073f7b47c31749efd6Satish Sampath
2075f9acde27486bcc6eea1092073f7b47c31749efd6Satish Sampath    /**
2076f9acde27486bcc6eea1092073f7b47c31749efd6Satish Sampath     * Sets the default searchable activity for web searches.
2077f9acde27486bcc6eea1092073f7b47c31749efd6Satish Sampath     *
2078f9acde27486bcc6eea1092073f7b47c31749efd6Satish Sampath     * @param component Name of the component to set as default activity for web searches.
2079f9acde27486bcc6eea1092073f7b47c31749efd6Satish Sampath     *
2080f9acde27486bcc6eea1092073f7b47c31749efd6Satish Sampath     * @hide
2081f9acde27486bcc6eea1092073f7b47c31749efd6Satish Sampath     */
20828d1538237847baf381787b881141f8c0478bef5bBjorn Bringert    public void setDefaultWebSearch(ComponentName component) {
2083f9acde27486bcc6eea1092073f7b47c31749efd6Satish Sampath        try {
20848d1538237847baf381787b881141f8c0478bef5bBjorn Bringert            mService.setDefaultWebSearch(component);
2085f9acde27486bcc6eea1092073f7b47c31749efd6Satish Sampath        } catch (RemoteException e) {
20868d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert            Log.e(TAG, "setDefaultWebSearch() failed: " + e);
2087f9acde27486bcc6eea1092073f7b47c31749efd6Satish Sampath        }
2088f9acde27486bcc6eea1092073f7b47c31749efd6Satish Sampath    }
20898d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert
20908d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert    private static void debug(String msg) {
20918d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert        Thread thread = Thread.currentThread();
20928d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert        Log.d(TAG, msg + " (" + thread.getName() + "-" + thread.getId() + ")");
20938d17f3f24bbda9a9cd7ea08c5925508dc2c011beBjorn Bringert    }
2094d27b10837525f341eee7d46013e2177b0bad3c60Scott Main}