The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package android.app; |
| 18 | |
Bjorn Bringert | 3c50ef6 | 2009-12-09 12:23:12 +0000 | [diff] [blame] | 19 | import android.content.ActivityNotFoundException; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 20 | import android.content.ComponentName; |
Karl Rosaen | 875d50a | 2009-04-23 19:00:21 -0700 | [diff] [blame] | 21 | import android.content.ContentResolver; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 22 | import android.content.Context; |
| 23 | import android.content.DialogInterface; |
Bjorn Bringert | 3c50ef6 | 2009-12-09 12:23:12 +0000 | [diff] [blame] | 24 | import android.content.Intent; |
Narayan Kamath | ee69ff4 | 2011-06-28 12:07:18 +0100 | [diff] [blame] | 25 | import android.content.pm.ResolveInfo; |
Karl Rosaen | 875d50a | 2009-04-23 19:00:21 -0700 | [diff] [blame] | 26 | import android.database.Cursor; |
Mathew Inwood | 050453e | 2011-10-13 11:00:39 +0100 | [diff] [blame] | 27 | import android.graphics.Rect; |
Karl Rosaen | 875d50a | 2009-04-23 19:00:21 -0700 | [diff] [blame] | 28 | import android.net.Uri; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 29 | import android.os.Bundle; |
| 30 | import android.os.Handler; |
Karl Rosaen | 875d50a | 2009-04-23 19:00:21 -0700 | [diff] [blame] | 31 | import android.os.RemoteException; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 32 | import android.os.ServiceManager; |
Dianne Hackborn | f02b60a | 2012-08-16 10:48:27 -0700 | [diff] [blame] | 33 | import android.os.UserHandle; |
Bjorn Bringert | 3fc7c67 | 2009-09-28 20:11:52 +0100 | [diff] [blame] | 34 | import android.text.TextUtils; |
Bjorn Bringert | 8d17f3f | 2009-06-05 13:22:28 +0100 | [diff] [blame] | 35 | import android.util.Log; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 36 | import android.view.KeyEvent; |
| 37 | |
Bjorn Bringert | 6d72e02 | 2009-04-29 14:56:12 +0100 | [diff] [blame] | 38 | import java.util.List; |
| 39 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 40 | /** |
| 41 | * This class provides access to the system search services. |
Amith Yamasani | e678f46 | 2010-09-15 16:13:43 -0700 | [diff] [blame] | 42 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 43 | * <p>In practice, you won't interact with this class directly, as search |
| 44 | * services are provided through methods in {@link android.app.Activity Activity} |
Scott Main | 8ad6465 | 2010-03-17 12:06:06 -0700 | [diff] [blame] | 45 | * and the {@link android.content.Intent#ACTION_SEARCH ACTION_SEARCH} |
| 46 | * {@link android.content.Intent Intent}. |
| 47 | * If you do require direct access to the SearchManager, do not instantiate |
| 48 | * this class directly. Instead, retrieve it through |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 49 | * {@link android.content.Context#getSystemService |
| 50 | * context.getSystemService(Context.SEARCH_SERVICE)}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 51 | * |
Joe Fernandez | 3aef8e1d | 2011-12-20 10:38:34 -0800 | [diff] [blame] | 52 | * <div class="special reference"> |
| 53 | * <h3>Developer Guides</h3> |
| 54 | * <p>For more information about using the search dialog and adding search |
| 55 | * suggestions in your application, read the |
| 56 | * <a href="{@docRoot}guide/topics/search/index.html">Search</a> developer guide.</p> |
Scott Main | 8ad6465 | 2010-03-17 12:06:06 -0700 | [diff] [blame] | 57 | * </div> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 58 | */ |
Amith Yamasani | e678f46 | 2010-09-15 16:13:43 -0700 | [diff] [blame] | 59 | public class SearchManager |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 60 | implements DialogInterface.OnDismissListener, DialogInterface.OnCancelListener |
| 61 | { |
Bjorn Bringert | 8d17f3f | 2009-06-05 13:22:28 +0100 | [diff] [blame] | 62 | |
| 63 | private static final boolean DBG = false; |
| 64 | private static final String TAG = "SearchManager"; |
| 65 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 66 | /** |
| 67 | * This is a shortcut definition for the default menu key to use for invoking search. |
Amith Yamasani | e678f46 | 2010-09-15 16:13:43 -0700 | [diff] [blame] | 68 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 69 | * See Menu.Item.setAlphabeticShortcut() for more information. |
| 70 | */ |
| 71 | public final static char MENU_KEY = 's'; |
| 72 | |
| 73 | /** |
| 74 | * This is a shortcut definition for the default menu key to use for invoking search. |
Amith Yamasani | e678f46 | 2010-09-15 16:13:43 -0700 | [diff] [blame] | 75 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 76 | * See Menu.Item.setAlphabeticShortcut() for more information. |
| 77 | */ |
| 78 | public final static int MENU_KEYCODE = KeyEvent.KEYCODE_S; |
| 79 | |
| 80 | /** |
Amith Yamasani | e678f46 | 2010-09-15 16:13:43 -0700 | [diff] [blame] | 81 | * Intent extra data key: Use this key with |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 82 | * {@link android.content.Intent#getStringExtra |
| 83 | * content.Intent.getStringExtra()} |
| 84 | * to obtain the query string from Intent.ACTION_SEARCH. |
| 85 | */ |
| 86 | public final static String QUERY = "query"; |
| 87 | |
| 88 | /** |
Bjorn Bringert | 5f80605 | 2009-06-24 12:02:26 +0100 | [diff] [blame] | 89 | * Intent extra data key: Use this key with |
| 90 | * {@link android.content.Intent#getStringExtra |
| 91 | * content.Intent.getStringExtra()} |
| 92 | * to obtain the query string typed in by the user. |
| 93 | * This may be different from the value of {@link #QUERY} |
| 94 | * if the intent is the result of selecting a suggestion. |
| 95 | * In that case, {@link #QUERY} will contain the value of |
| 96 | * {@link #SUGGEST_COLUMN_QUERY} for the suggestion, and |
| 97 | * {@link #USER_QUERY} will contain the string typed by the |
| 98 | * user. |
| 99 | */ |
| 100 | public final static String USER_QUERY = "user_query"; |
| 101 | |
| 102 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 103 | * Intent extra data key: Use this key with Intent.ACTION_SEARCH and |
| 104 | * {@link android.content.Intent#getBundleExtra |
| 105 | * content.Intent.getBundleExtra()} |
Amith Yamasani | e678f46 | 2010-09-15 16:13:43 -0700 | [diff] [blame] | 106 | * to obtain any additional app-specific data that was inserted by the |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 107 | * activity that launched the search. |
| 108 | */ |
| 109 | public final static String APP_DATA = "app_data"; |
| 110 | |
| 111 | /** |
Bjorn Bringert | be5b73c | 2009-09-21 23:05:23 +0100 | [diff] [blame] | 112 | * Intent extra data key: Use {@link android.content.Intent#getBundleExtra |
| 113 | * content.Intent.getBundleExtra(SEARCH_MODE)} to get the search mode used |
| 114 | * to launch the intent. |
| 115 | * The only current value for this is {@link #MODE_GLOBAL_SEARCH_SUGGESTION}. |
| 116 | * |
| 117 | * @hide |
| 118 | */ |
| 119 | public final static String SEARCH_MODE = "search_mode"; |
| 120 | |
| 121 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 122 | * Intent extra data key: Use this key with Intent.ACTION_SEARCH and |
| 123 | * {@link android.content.Intent#getIntExtra content.Intent.getIntExtra()} |
| 124 | * to obtain the keycode that the user used to trigger this query. It will be zero if the |
| 125 | * user simply pressed the "GO" button on the search UI. This is primarily used in conjunction |
| 126 | * with the keycode attribute in the actionkey element of your searchable.xml configuration |
| 127 | * file. |
| 128 | */ |
| 129 | public final static String ACTION_KEY = "action_key"; |
Amith Yamasani | e678f46 | 2010-09-15 16:13:43 -0700 | [diff] [blame] | 130 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 131 | /** |
Karl Rosaen | 875d50a | 2009-04-23 19:00:21 -0700 | [diff] [blame] | 132 | * Intent extra data key: This key will be used for the extra populated by the |
| 133 | * {@link #SUGGEST_COLUMN_INTENT_EXTRA_DATA} column. |
Karl Rosaen | 875d50a | 2009-04-23 19:00:21 -0700 | [diff] [blame] | 134 | */ |
| 135 | public final static String EXTRA_DATA_KEY = "intent_extra_data_key"; |
Karl Rosaen | a058f02 | 2009-06-01 23:11:44 +0100 | [diff] [blame] | 136 | |
Karl Rosaen | a058f02 | 2009-06-01 23:11:44 +0100 | [diff] [blame] | 137 | /** |
Bjorn Bringert | 55f3ac5 | 2010-01-14 11:38:22 +0000 | [diff] [blame] | 138 | * Boolean extra data key for {@link #INTENT_ACTION_GLOBAL_SEARCH} intents. If {@code true}, |
| 139 | * the initial query should be selected when the global search activity is started, so |
| 140 | * that the user can easily replace it with another query. |
Bjorn Bringert | 3c50ef6 | 2009-12-09 12:23:12 +0000 | [diff] [blame] | 141 | */ |
Bjorn Bringert | 55f3ac5 | 2010-01-14 11:38:22 +0000 | [diff] [blame] | 142 | public final static String EXTRA_SELECT_QUERY = "select_query"; |
Bjorn Bringert | 32d580c | 2010-01-06 09:29:11 +0000 | [diff] [blame] | 143 | |
Bjorn Bringert | 3c50ef6 | 2009-12-09 12:23:12 +0000 | [diff] [blame] | 144 | /** |
Leon Scroggins | af5b406 | 2011-02-22 16:35:13 -0500 | [diff] [blame] | 145 | * Boolean extra data key for {@link Intent#ACTION_WEB_SEARCH} intents. If {@code true}, |
| 146 | * this search should open a new browser window, rather than using an existing one. |
| 147 | */ |
| 148 | public final static String EXTRA_NEW_SEARCH = "new_search"; |
| 149 | |
| 150 | /** |
Bjorn Bringert | 4519ff6 | 2011-08-10 15:42:11 -0700 | [diff] [blame] | 151 | * Extra data key for {@link Intent#ACTION_WEB_SEARCH}. If set, the value must be a |
| 152 | * {@link PendingIntent}. The search activity handling the {@link Intent#ACTION_WEB_SEARCH} |
| 153 | * intent will fill in and launch the pending intent. The data URI will be filled in with an |
| 154 | * http or https URI, and {@link android.provider.Browser#EXTRA_HEADERS} may be filled in. |
| 155 | */ |
| 156 | public static final String EXTRA_WEB_SEARCH_PENDINGINTENT = "web_search_pendingintent"; |
| 157 | |
| 158 | /** |
Amith Yamasani | c37cb24 | 2010-02-24 17:44:46 -0800 | [diff] [blame] | 159 | * Boolean extra data key for a suggestion provider to return in {@link Cursor#getExtras} to |
| 160 | * indicate that the search is not complete yet. This can be used by the search UI |
| 161 | * to indicate that a search is in progress. The suggestion provider can return partial results |
| 162 | * this way and send a change notification on the cursor when more results are available. |
| 163 | */ |
| 164 | public final static String CURSOR_EXTRA_KEY_IN_PROGRESS = "in_progress"; |
| 165 | |
| 166 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 167 | * Intent extra data key: Use this key with Intent.ACTION_SEARCH and |
| 168 | * {@link android.content.Intent#getStringExtra content.Intent.getStringExtra()} |
| 169 | * to obtain the action message that was defined for a particular search action key and/or |
Amith Yamasani | e678f46 | 2010-09-15 16:13:43 -0700 | [diff] [blame] | 170 | * suggestion. It will be null if the search was launched by typing "enter", touched the the |
| 171 | * "GO" button, or other means not involving any action key. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 172 | */ |
| 173 | public final static String ACTION_MSG = "action_msg"; |
Amith Yamasani | e678f46 | 2010-09-15 16:13:43 -0700 | [diff] [blame] | 174 | |
| 175 | /** |
| 176 | * Flag to specify that the entry can be used for query refinement, i.e., the query text |
| 177 | * in the search field can be replaced with the text in this entry, when a query refinement |
| 178 | * icon is clicked. The suggestion list should show such a clickable icon beside the entry. |
| 179 | * <p>Use this flag as a bit-field for {@link #SUGGEST_COLUMN_FLAGS}. |
| 180 | */ |
| 181 | public final static int FLAG_QUERY_REFINEMENT = 1 << 0; |
| 182 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 183 | /** |
| 184 | * Uri path for queried suggestions data. This is the path that the search manager |
| 185 | * will use when querying your content provider for suggestions data based on user input |
| 186 | * (e.g. looking for partial matches). |
| 187 | * Typically you'll use this with a URI matcher. |
| 188 | */ |
| 189 | public final static String SUGGEST_URI_PATH_QUERY = "search_suggest_query"; |
Karl Rosaen | b2a5011 | 2009-05-05 21:14:01 -0700 | [diff] [blame] | 190 | |
| 191 | /** |
Karl Rosaen | b619c91 | 2009-05-08 14:28:51 -0700 | [diff] [blame] | 192 | * MIME type for suggestions data. You'll use this in your suggestions content provider |
| 193 | * in the getType() function. |
| 194 | */ |
| 195 | public final static String SUGGEST_MIME_TYPE = |
| 196 | "vnd.android.cursor.dir/vnd.android.search.suggest"; |
| 197 | |
| 198 | /** |
Karl Rosaen | b2a5011 | 2009-05-05 21:14:01 -0700 | [diff] [blame] | 199 | * Uri path for shortcut validation. This is the path that the search manager will use when |
| 200 | * querying your content provider to refresh a shortcutted suggestion result and to check if it |
| 201 | * is still valid. When asked, a source may return an up to date result, or no result. No |
| 202 | * result indicates the shortcut refers to a no longer valid sugggestion. |
| 203 | * |
| 204 | * @see #SUGGEST_COLUMN_SHORTCUT_ID |
Karl Rosaen | b2a5011 | 2009-05-05 21:14:01 -0700 | [diff] [blame] | 205 | */ |
| 206 | public final static String SUGGEST_URI_PATH_SHORTCUT = "search_suggest_shortcut"; |
Amith Yamasani | e678f46 | 2010-09-15 16:13:43 -0700 | [diff] [blame] | 207 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 208 | /** |
Karl Rosaen | b619c91 | 2009-05-08 14:28:51 -0700 | [diff] [blame] | 209 | * MIME type for shortcut validation. You'll use this in your suggestions content provider |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 210 | * in the getType() function. |
| 211 | */ |
Amith Yamasani | e678f46 | 2010-09-15 16:13:43 -0700 | [diff] [blame] | 212 | public final static String SHORTCUT_MIME_TYPE = |
Karl Rosaen | b619c91 | 2009-05-08 14:28:51 -0700 | [diff] [blame] | 213 | "vnd.android.cursor.item/vnd.android.search.suggest"; |
Karl Rosaen | d4c98c4 | 2009-06-09 17:05:54 +0100 | [diff] [blame] | 214 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 215 | /** |
| 216 | * Column name for suggestions cursor. <i>Unused - can be null or column can be omitted.</i> |
| 217 | */ |
| 218 | public final static String SUGGEST_COLUMN_FORMAT = "suggest_format"; |
| 219 | /** |
Amith Yamasani | e678f46 | 2010-09-15 16:13:43 -0700 | [diff] [blame] | 220 | * Column name for suggestions cursor. <i>Required.</i> This is the primary line of text that |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 221 | * will be presented to the user as the suggestion. |
| 222 | */ |
| 223 | public final static String SUGGEST_COLUMN_TEXT_1 = "suggest_text_1"; |
| 224 | /** |
| 225 | * Column name for suggestions cursor. <i>Optional.</i> If your cursor includes this column, |
| 226 | * then all suggestions will be provided in a two-line format. The second line of text is in |
| 227 | * a much smaller appearance. |
| 228 | */ |
| 229 | public final static String SUGGEST_COLUMN_TEXT_2 = "suggest_text_2"; |
Bjorn Bringert | 0b49ab5 | 2010-03-02 11:16:17 +0000 | [diff] [blame] | 230 | |
| 231 | /** |
| 232 | * Column name for suggestions cursor. <i>Optional.</i> This is a URL that will be shown |
| 233 | * as the second line of text instead of {@link #SUGGEST_COLUMN_TEXT_2}. This is a separate |
| 234 | * column so that the search UI knows to display the text as a URL, e.g. by using a different |
| 235 | * color. If this column is absent, or has the value {@code null}, |
| 236 | * {@link #SUGGEST_COLUMN_TEXT_2} will be used instead. |
| 237 | */ |
| 238 | public final static String SUGGEST_COLUMN_TEXT_2_URL = "suggest_text_2_url"; |
| 239 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 240 | /** |
| 241 | * Column name for suggestions cursor. <i>Optional.</i> If your cursor includes this column, |
Karl Rosaen | 875d50a | 2009-04-23 19:00:21 -0700 | [diff] [blame] | 242 | * then all suggestions will be provided in a format that includes space for two small icons, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 243 | * one at the left and one at the right of each suggestion. The data in the column must |
Karl Rosaen | 875d50a | 2009-04-23 19:00:21 -0700 | [diff] [blame] | 244 | * be a resource ID of a drawable, or a URI in one of the following formats: |
| 245 | * |
| 246 | * <ul> |
| 247 | * <li>content ({@link android.content.ContentResolver#SCHEME_CONTENT})</li> |
| 248 | * <li>android.resource ({@link android.content.ContentResolver#SCHEME_ANDROID_RESOURCE})</li> |
| 249 | * <li>file ({@link android.content.ContentResolver#SCHEME_FILE})</li> |
| 250 | * </ul> |
| 251 | * |
Amith Yamasani | e678f46 | 2010-09-15 16:13:43 -0700 | [diff] [blame] | 252 | * See {@link android.content.ContentResolver#openAssetFileDescriptor(Uri, String)} |
| 253 | * for more information on these schemes. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 254 | */ |
| 255 | public final static String SUGGEST_COLUMN_ICON_1 = "suggest_icon_1"; |
| 256 | /** |
| 257 | * Column name for suggestions cursor. <i>Optional.</i> If your cursor includes this column, |
Karl Rosaen | 875d50a | 2009-04-23 19:00:21 -0700 | [diff] [blame] | 258 | * then all suggestions will be provided in a format that includes space for two small icons, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 259 | * one at the left and one at the right of each suggestion. The data in the column must |
Karl Rosaen | 875d50a | 2009-04-23 19:00:21 -0700 | [diff] [blame] | 260 | * be a resource ID of a drawable, or a URI in one of the following formats: |
| 261 | * |
| 262 | * <ul> |
| 263 | * <li>content ({@link android.content.ContentResolver#SCHEME_CONTENT})</li> |
| 264 | * <li>android.resource ({@link android.content.ContentResolver#SCHEME_ANDROID_RESOURCE})</li> |
| 265 | * <li>file ({@link android.content.ContentResolver#SCHEME_FILE})</li> |
| 266 | * </ul> |
| 267 | * |
Amith Yamasani | e678f46 | 2010-09-15 16:13:43 -0700 | [diff] [blame] | 268 | * See {@link android.content.ContentResolver#openAssetFileDescriptor(Uri, String)} |
| 269 | * for more information on these schemes. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 270 | */ |
| 271 | public final static String SUGGEST_COLUMN_ICON_2 = "suggest_icon_2"; |
| 272 | /** |
| 273 | * Column name for suggestions cursor. <i>Optional.</i> If this column exists <i>and</i> |
| 274 | * this element exists at the given row, this is the action that will be used when |
| 275 | * forming the suggestion's intent. If the element is not provided, the action will be taken |
| 276 | * from the android:searchSuggestIntentAction field in your XML metadata. <i>At least one of |
| 277 | * these must be present for the suggestion to generate an intent.</i> Note: If your action is |
| 278 | * the same for all suggestions, it is more efficient to specify it using XML metadata and omit |
| 279 | * it from the cursor. |
| 280 | */ |
| 281 | public final static String SUGGEST_COLUMN_INTENT_ACTION = "suggest_intent_action"; |
| 282 | /** |
| 283 | * Column name for suggestions cursor. <i>Optional.</i> If this column exists <i>and</i> |
| 284 | * this element exists at the given row, this is the data that will be used when |
| 285 | * forming the suggestion's intent. If the element is not provided, the data will be taken |
| 286 | * from the android:searchSuggestIntentData field in your XML metadata. If neither source |
| 287 | * is provided, the Intent's data field will be null. Note: If your data is |
| 288 | * the same for all suggestions, or can be described using a constant part and a specific ID, |
| 289 | * it is more efficient to specify it using XML metadata and omit it from the cursor. |
| 290 | */ |
| 291 | public final static String SUGGEST_COLUMN_INTENT_DATA = "suggest_intent_data"; |
| 292 | /** |
Satish Sampath | bf23fe0 | 2009-06-15 23:47:56 +0100 | [diff] [blame] | 293 | * Column name for suggestions cursor. <i>Optional.</i> If this column exists <i>and</i> |
| 294 | * this element exists at the given row, this is the data that will be used when |
| 295 | * forming the suggestion's intent. If not provided, the Intent's extra data field will be null. |
| 296 | * This column allows suggestions to provide additional arbitrary data which will be included as |
Mike LeBeau | 131234c | 2009-07-20 14:09:52 -0700 | [diff] [blame] | 297 | * an extra under the key {@link #EXTRA_DATA_KEY}. |
Satish Sampath | bf23fe0 | 2009-06-15 23:47:56 +0100 | [diff] [blame] | 298 | */ |
| 299 | public final static String SUGGEST_COLUMN_INTENT_EXTRA_DATA = "suggest_intent_extra_data"; |
| 300 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 301 | * Column name for suggestions cursor. <i>Optional.</i> If this column exists <i>and</i> |
| 302 | * this element exists at the given row, then "/" and this value will be appended to the data |
| 303 | * field in the Intent. This should only be used if the data field has already been set to an |
| 304 | * appropriate base string. |
| 305 | */ |
| 306 | public final static String SUGGEST_COLUMN_INTENT_DATA_ID = "suggest_intent_data_id"; |
| 307 | /** |
Amith Yamasani | e678f46 | 2010-09-15 16:13:43 -0700 | [diff] [blame] | 308 | * Column name for suggestions cursor. <i>Required if action is |
| 309 | * {@link android.content.Intent#ACTION_SEARCH ACTION_SEARCH}, optional otherwise.</i> If this |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 310 | * column exists <i>and</i> this element exists at the given row, this is the data that will be |
| 311 | * used when forming the suggestion's query. |
| 312 | */ |
| 313 | public final static String SUGGEST_COLUMN_QUERY = "suggest_intent_query"; |
| 314 | |
Karl Rosaen | 875d50a | 2009-04-23 19:00:21 -0700 | [diff] [blame] | 315 | /** |
Karl Rosaen | b2a5011 | 2009-05-05 21:14:01 -0700 | [diff] [blame] | 316 | * Column name for suggestions cursor. <i>Optional.</i> This column is used to indicate whether |
Karl Rosaen | b504136 | 2009-08-11 11:35:07 -0700 | [diff] [blame] | 317 | * a search suggestion should be stored as a shortcut, and whether it should be refreshed. If |
Karl Rosaen | b2a5011 | 2009-05-05 21:14:01 -0700 | [diff] [blame] | 318 | * missing, the result will be stored as a shortcut and never validated. If set to |
| 319 | * {@link #SUGGEST_NEVER_MAKE_SHORTCUT}, the result will not be stored as a shortcut. |
Karl Rosaen | b504136 | 2009-08-11 11:35:07 -0700 | [diff] [blame] | 320 | * Otherwise, the shortcut id will be used to check back for an up to date suggestion using |
Karl Rosaen | b2a5011 | 2009-05-05 21:14:01 -0700 | [diff] [blame] | 321 | * {@link #SUGGEST_URI_PATH_SHORTCUT}. |
Karl Rosaen | b2a5011 | 2009-05-05 21:14:01 -0700 | [diff] [blame] | 322 | */ |
| 323 | public final static String SUGGEST_COLUMN_SHORTCUT_ID = "suggest_shortcut_id"; |
| 324 | |
| 325 | /** |
Mike LeBeau | ce0959d | 2009-06-10 23:47:54 +0100 | [diff] [blame] | 326 | * Column name for suggestions cursor. <i>Optional.</i> This column is used to specify |
| 327 | * that a spinner should be shown in lieu of an icon2 while the shortcut of this suggestion |
| 328 | * is being refreshed. |
Mike LeBeau | ce0959d | 2009-06-10 23:47:54 +0100 | [diff] [blame] | 329 | */ |
| 330 | public final static String SUGGEST_COLUMN_SPINNER_WHILE_REFRESHING = |
| 331 | "suggest_spinner_while_refreshing"; |
Satish Sampath | 1c5fa0f | 2009-06-08 23:10:40 +0100 | [diff] [blame] | 332 | |
| 333 | /** |
Amith Yamasani | e678f46 | 2010-09-15 16:13:43 -0700 | [diff] [blame] | 334 | * Column name for suggestions cursor. <i>Optional.</i> This column is used to specify |
| 335 | * additional flags per item. Multiple flags can be specified. |
| 336 | * <p> |
| 337 | * Must be one of {@link #FLAG_QUERY_REFINEMENT} or 0 to indicate no flags. |
| 338 | * </p> |
| 339 | */ |
| 340 | public final static String SUGGEST_COLUMN_FLAGS = "suggest_flags"; |
| 341 | |
| 342 | /** |
Mark Brophy | a31c7aa | 2011-06-17 16:36:38 +0100 | [diff] [blame] | 343 | * Column name for suggestions cursor. <i>Optional.</i> This column may be |
Mark Brophy | de2ba4c | 2011-09-16 12:27:20 +0100 | [diff] [blame] | 344 | * used to specify the time in {@link System#currentTimeMillis |
Mark Brophy | a31c7aa | 2011-06-17 16:36:38 +0100 | [diff] [blame] | 345 | * System.currentTImeMillis()} (wall time in UTC) when an item was last |
| 346 | * accessed within the results-providing application. If set, this may be |
| 347 | * used to show more-recently-used items first. |
| 348 | */ |
| 349 | public final static String SUGGEST_COLUMN_LAST_ACCESS_HINT = "suggest_last_access_hint"; |
| 350 | |
| 351 | /** |
Karl Rosaen | b2a5011 | 2009-05-05 21:14:01 -0700 | [diff] [blame] | 352 | * Column value for suggestion column {@link #SUGGEST_COLUMN_SHORTCUT_ID} when a suggestion |
| 353 | * should not be stored as a shortcut in global search. |
Karl Rosaen | b2a5011 | 2009-05-05 21:14:01 -0700 | [diff] [blame] | 354 | */ |
| 355 | public final static String SUGGEST_NEVER_MAKE_SHORTCUT = "_-1"; |
| 356 | |
| 357 | /** |
Bjorn Bringert | 3fc7c67 | 2009-09-28 20:11:52 +0100 | [diff] [blame] | 358 | * Query parameter added to suggestion queries to limit the number of suggestions returned. |
Bjorn Bringert | 86917db | 2009-09-28 22:00:50 +0100 | [diff] [blame] | 359 | * This limit is only advisory and suggestion providers may chose to ignore it. |
Bjorn Bringert | 3fc7c67 | 2009-09-28 20:11:52 +0100 | [diff] [blame] | 360 | */ |
| 361 | public final static String SUGGEST_PARAMETER_LIMIT = "limit"; |
| 362 | |
| 363 | /** |
Bjorn Bringert | 55f3ac5 | 2010-01-14 11:38:22 +0000 | [diff] [blame] | 364 | * Intent action for starting the global search activity. |
Bjorn Bringert | 74708bb | 2009-04-28 11:26:52 +0100 | [diff] [blame] | 365 | * The global search provider should handle this intent. |
Bjorn Bringert | 55f3ac5 | 2010-01-14 11:38:22 +0000 | [diff] [blame] | 366 | * |
| 367 | * Supported extra data keys: {@link #QUERY}, |
| 368 | * {@link #EXTRA_SELECT_QUERY}, |
| 369 | * {@link #APP_DATA}. |
Bjorn Bringert | 74708bb | 2009-04-28 11:26:52 +0100 | [diff] [blame] | 370 | */ |
Amith Yamasani | e678f46 | 2010-09-15 16:13:43 -0700 | [diff] [blame] | 371 | public final static String INTENT_ACTION_GLOBAL_SEARCH |
Bjorn Bringert | 74708bb | 2009-04-28 11:26:52 +0100 | [diff] [blame] | 372 | = "android.search.action.GLOBAL_SEARCH"; |
Amith Yamasani | e678f46 | 2010-09-15 16:13:43 -0700 | [diff] [blame] | 373 | |
Bjorn Bringert | 74708bb | 2009-04-28 11:26:52 +0100 | [diff] [blame] | 374 | /** |
Karl Rosaen | 875d50a | 2009-04-23 19:00:21 -0700 | [diff] [blame] | 375 | * Intent action for starting the global search settings activity. |
| 376 | * The global search provider should handle this intent. |
Karl Rosaen | 875d50a | 2009-04-23 19:00:21 -0700 | [diff] [blame] | 377 | */ |
Amith Yamasani | e678f46 | 2010-09-15 16:13:43 -0700 | [diff] [blame] | 378 | public final static String INTENT_ACTION_SEARCH_SETTINGS |
Karl Rosaen | 875d50a | 2009-04-23 19:00:21 -0700 | [diff] [blame] | 379 | = "android.search.action.SEARCH_SETTINGS"; |
Amith Yamasani | e678f46 | 2010-09-15 16:13:43 -0700 | [diff] [blame] | 380 | |
Mike LeBeau | 3a27803 | 2009-06-04 14:09:42 +0100 | [diff] [blame] | 381 | /** |
| 382 | * Intent action for starting a web search provider's settings activity. |
| 383 | * Web search providers should handle this intent if they have provider-specific |
| 384 | * settings to implement. |
Mike LeBeau | 3a27803 | 2009-06-04 14:09:42 +0100 | [diff] [blame] | 385 | */ |
| 386 | public final static String INTENT_ACTION_WEB_SEARCH_SETTINGS |
| 387 | = "android.search.action.WEB_SEARCH_SETTINGS"; |
Karl Rosaen | a058f02 | 2009-06-01 23:11:44 +0100 | [diff] [blame] | 388 | |
| 389 | /** |
Satish Sampath | f9acde2 | 2009-06-04 11:51:17 +0100 | [diff] [blame] | 390 | * Intent action broadcasted to inform that the searchables list or default have changed. |
| 391 | * Components should handle this intent if they cache any searchable data and wish to stay |
| 392 | * up to date on changes. |
Satish Sampath | f9acde2 | 2009-06-04 11:51:17 +0100 | [diff] [blame] | 393 | */ |
| 394 | public final static String INTENT_ACTION_SEARCHABLES_CHANGED |
| 395 | = "android.search.action.SEARCHABLES_CHANGED"; |
Amith Yamasani | e678f46 | 2010-09-15 16:13:43 -0700 | [diff] [blame] | 396 | |
Mike LeBeau | d4fb7a0 | 2009-07-20 17:37:38 -0700 | [diff] [blame] | 397 | /** |
Narayan Kamath | ee69ff4 | 2011-06-28 12:07:18 +0100 | [diff] [blame] | 398 | * Intent action to be broadcast to inform that the global search provider |
Michael Jurka | 3f5cfcf | 2012-04-27 14:20:59 -0700 | [diff] [blame] | 399 | * has changed. |
Narayan Kamath | ee69ff4 | 2011-06-28 12:07:18 +0100 | [diff] [blame] | 400 | */ |
| 401 | public final static String INTENT_GLOBAL_SEARCH_ACTIVITY_CHANGED |
| 402 | = "android.search.action.GLOBAL_SEARCH_ACTIVITY_CHANGED"; |
| 403 | |
| 404 | /** |
Mike LeBeau | d4fb7a0 | 2009-07-20 17:37:38 -0700 | [diff] [blame] | 405 | * Intent action broadcasted to inform that the search settings have changed in some way. |
Karl Rosaen | 590f634 | 2009-08-27 17:42:48 -0700 | [diff] [blame] | 406 | * Either searchables have been enabled or disabled, or a different web search provider |
| 407 | * has been chosen. |
Mike LeBeau | d4fb7a0 | 2009-07-20 17:37:38 -0700 | [diff] [blame] | 408 | */ |
| 409 | public final static String INTENT_ACTION_SEARCH_SETTINGS_CHANGED |
| 410 | = "android.search.action.SETTINGS_CHANGED"; |
Satish Sampath | f9acde2 | 2009-06-04 11:51:17 +0100 | [diff] [blame] | 411 | |
| 412 | /** |
Leon Scroggins | 4f22a54 | 2010-03-09 17:28:13 -0500 | [diff] [blame] | 413 | * This means that context is voice, and therefore the SearchDialog should |
| 414 | * continue showing the microphone until the user indicates that he/she does |
| 415 | * not want to re-speak (e.g. by typing). |
| 416 | * |
| 417 | * @hide |
| 418 | */ |
| 419 | public final static String CONTEXT_IS_VOICE = "android.search.CONTEXT_IS_VOICE"; |
| 420 | |
| 421 | /** |
Leon Scroggins III | 4a02800 | 2010-09-14 10:56:25 -0400 | [diff] [blame] | 422 | * This means that the voice icon should not be shown at all, because the |
| 423 | * current search engine does not support voice search. |
| 424 | * @hide |
| 425 | */ |
| 426 | public final static String DISABLE_VOICE_SEARCH |
| 427 | = "android.search.DISABLE_VOICE_SEARCH"; |
| 428 | |
| 429 | /** |
Karl Rosaen | 875d50a | 2009-04-23 19:00:21 -0700 | [diff] [blame] | 430 | * Reference to the shared system search service. |
| 431 | */ |
Bjorn Bringert | 8d15382 | 2009-06-22 10:31:44 +0100 | [diff] [blame] | 432 | private static ISearchManager mService; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 433 | |
| 434 | private final Context mContext; |
Bjorn Bringert | 8d17f3f | 2009-06-05 13:22:28 +0100 | [diff] [blame] | 435 | |
krosaen | d2d6014 | 2009-08-17 08:56:48 -0700 | [diff] [blame] | 436 | /** |
krosaen | d2d6014 | 2009-08-17 08:56:48 -0700 | [diff] [blame] | 437 | * The package associated with this seach manager. |
| 438 | */ |
| 439 | private String mAssociatedPackage; |
Amith Yamasani | e678f46 | 2010-09-15 16:13:43 -0700 | [diff] [blame] | 440 | |
Bjorn Bringert | 8d17f3f | 2009-06-05 13:22:28 +0100 | [diff] [blame] | 441 | // package private since they are used by the inner class SearchManagerCallback |
Bjorn Bringert | 8d17f3f | 2009-06-05 13:22:28 +0100 | [diff] [blame] | 442 | /* package */ final Handler mHandler; |
| 443 | /* package */ OnDismissListener mDismissListener = null; |
| 444 | /* package */ OnCancelListener mCancelListener = null; |
| 445 | |
Amith Yamasani | e9ce3f0 | 2010-01-25 09:15:50 -0800 | [diff] [blame] | 446 | private SearchDialog mSearchDialog; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 447 | |
| 448 | /*package*/ SearchManager(Context context, Handler handler) { |
| 449 | mContext = context; |
| 450 | mHandler = handler; |
Bjorn Bringert | 8d15382 | 2009-06-22 10:31:44 +0100 | [diff] [blame] | 451 | mService = ISearchManager.Stub.asInterface( |
| 452 | ServiceManager.getService(Context.SEARCH_SERVICE)); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 453 | } |
Amith Yamasani | e678f46 | 2010-09-15 16:13:43 -0700 | [diff] [blame] | 454 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 455 | /** |
| 456 | * Launch search UI. |
| 457 | * |
| 458 | * <p>The search manager will open a search widget in an overlapping |
Amith Yamasani | e678f46 | 2010-09-15 16:13:43 -0700 | [diff] [blame] | 459 | * window, and the underlying activity may be obscured. The search |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 460 | * entry state will remain in effect until one of the following events: |
| 461 | * <ul> |
Amith Yamasani | e678f46 | 2010-09-15 16:13:43 -0700 | [diff] [blame] | 462 | * <li>The user completes the search. In most cases this will launch |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 463 | * a search intent.</li> |
| 464 | * <li>The user uses the back, home, or other keys to exit the search.</li> |
| 465 | * <li>The application calls the {@link #stopSearch} |
| 466 | * method, which will hide the search window and return focus to the |
| 467 | * activity from which it was launched.</li> |
| 468 | * |
| 469 | * <p>Most applications will <i>not</i> use this interface to invoke search. |
Amith Yamasani | e678f46 | 2010-09-15 16:13:43 -0700 | [diff] [blame] | 470 | * The primary method for invoking search is to call |
| 471 | * {@link android.app.Activity#onSearchRequested Activity.onSearchRequested()} or |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 472 | * {@link android.app.Activity#startSearch Activity.startSearch()}. |
| 473 | * |
| 474 | * @param initialQuery A search string can be pre-entered here, but this |
| 475 | * is typically null or empty. |
| 476 | * @param selectInitialQuery If true, the intial query will be preselected, which means that |
| 477 | * any further typing will replace it. This is useful for cases where an entire pre-formed |
| 478 | * query is being inserted. If false, the selection point will be placed at the end of the |
| 479 | * inserted query. This is useful when the inserted query is text that the user entered, |
| 480 | * and the user would expect to be able to keep typing. <i>This parameter is only meaningful |
| 481 | * if initialQuery is a non-empty string.</i> |
| 482 | * @param launchActivity The ComponentName of the activity that has launched this search. |
Amith Yamasani | e678f46 | 2010-09-15 16:13:43 -0700 | [diff] [blame] | 483 | * @param appSearchData An application can insert application-specific |
| 484 | * context here, in order to improve quality or specificity of its own |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 485 | * searches. This data will be returned with SEARCH intent(s). Null if |
| 486 | * no extra data is required. |
| 487 | * @param globalSearch If false, this will only launch the search that has been specifically |
Amith Yamasani | e678f46 | 2010-09-15 16:13:43 -0700 | [diff] [blame] | 488 | * defined by the application (which is usually defined as a local search). If no default |
Mike LeBeau | cfa419b | 2009-08-17 10:56:02 -0700 | [diff] [blame] | 489 | * search is defined in the current application or activity, global search will be launched. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 490 | * If true, this will always launch a platform-global (e.g. web-based) search instead. |
Amith Yamasani | e678f46 | 2010-09-15 16:13:43 -0700 | [diff] [blame] | 491 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 492 | * @see android.app.Activity#onSearchRequested |
| 493 | * @see #stopSearch |
| 494 | */ |
Amith Yamasani | e678f46 | 2010-09-15 16:13:43 -0700 | [diff] [blame] | 495 | public void startSearch(String initialQuery, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 496 | boolean selectInitialQuery, |
| 497 | ComponentName launchActivity, |
| 498 | Bundle appSearchData, |
| 499 | boolean globalSearch) { |
Mathew Inwood | 050453e | 2011-10-13 11:00:39 +0100 | [diff] [blame] | 500 | startSearch(initialQuery, selectInitialQuery, launchActivity, |
| 501 | appSearchData, globalSearch, null); |
| 502 | } |
| 503 | |
| 504 | /** |
| 505 | * As {@link #startSearch(String, boolean, ComponentName, Bundle, boolean)} but including |
| 506 | * source bounds for the global search intent. |
| 507 | * |
| 508 | * @hide |
| 509 | */ |
| 510 | public void startSearch(String initialQuery, |
| 511 | boolean selectInitialQuery, |
| 512 | ComponentName launchActivity, |
| 513 | Bundle appSearchData, |
| 514 | boolean globalSearch, |
| 515 | Rect sourceBounds) { |
Bjorn Bringert | 3c50ef6 | 2009-12-09 12:23:12 +0000 | [diff] [blame] | 516 | if (globalSearch) { |
Mathew Inwood | 050453e | 2011-10-13 11:00:39 +0100 | [diff] [blame] | 517 | startGlobalSearch(initialQuery, selectInitialQuery, appSearchData, sourceBounds); |
Bjorn Bringert | 3c50ef6 | 2009-12-09 12:23:12 +0000 | [diff] [blame] | 518 | return; |
| 519 | } |
| 520 | |
Amith Yamasani | 479ae0a | 2010-02-04 14:52:32 -0800 | [diff] [blame] | 521 | ensureSearchDialog(); |
| 522 | |
| 523 | mSearchDialog.show(initialQuery, selectInitialQuery, launchActivity, appSearchData); |
Amith Yamasani | e9ce3f0 | 2010-01-25 09:15:50 -0800 | [diff] [blame] | 524 | } |
| 525 | |
| 526 | private void ensureSearchDialog() { |
| 527 | if (mSearchDialog == null) { |
| 528 | mSearchDialog = new SearchDialog(mContext, this); |
| 529 | mSearchDialog.setOnCancelListener(this); |
| 530 | mSearchDialog.setOnDismissListener(this); |
krosaen | d2d6014 | 2009-08-17 08:56:48 -0700 | [diff] [blame] | 531 | } |
| 532 | } |
| 533 | |
| 534 | /** |
Bjorn Bringert | 3c50ef6 | 2009-12-09 12:23:12 +0000 | [diff] [blame] | 535 | * Starts the global search activity. |
| 536 | */ |
Amith Yamasani | e9ce3f0 | 2010-01-25 09:15:50 -0800 | [diff] [blame] | 537 | /* package */ void startGlobalSearch(String initialQuery, boolean selectInitialQuery, |
Mathew Inwood | 050453e | 2011-10-13 11:00:39 +0100 | [diff] [blame] | 538 | Bundle appSearchData, Rect sourceBounds) { |
Bjorn Bringert | 3c50ef6 | 2009-12-09 12:23:12 +0000 | [diff] [blame] | 539 | ComponentName globalSearchActivity = getGlobalSearchActivity(); |
| 540 | if (globalSearchActivity == null) { |
| 541 | Log.w(TAG, "No global search activity found."); |
| 542 | return; |
| 543 | } |
Bjorn Bringert | a94e7af | 2010-01-13 21:09:20 +0000 | [diff] [blame] | 544 | Intent intent = new Intent(INTENT_ACTION_GLOBAL_SEARCH); |
Bjorn Bringert | b8144a9 | 2010-02-22 20:48:57 +0000 | [diff] [blame] | 545 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
Bjorn Bringert | 3c50ef6 | 2009-12-09 12:23:12 +0000 | [diff] [blame] | 546 | intent.setComponent(globalSearchActivity); |
Bjorn Bringert | 3c24cb7 | 2010-03-16 12:54:41 +0000 | [diff] [blame] | 547 | // Make sure that we have a Bundle to put source in |
| 548 | if (appSearchData == null) { |
| 549 | appSearchData = new Bundle(); |
| 550 | } else { |
| 551 | appSearchData = new Bundle(appSearchData); |
Bjorn Bringert | 3c50ef6 | 2009-12-09 12:23:12 +0000 | [diff] [blame] | 552 | } |
Bjorn Bringert | 3c24cb7 | 2010-03-16 12:54:41 +0000 | [diff] [blame] | 553 | // Set source to package name of app that starts global search, if not set already. |
| 554 | if (!appSearchData.containsKey("source")) { |
| 555 | appSearchData.putString("source", mContext.getPackageName()); |
| 556 | } |
| 557 | intent.putExtra(APP_DATA, appSearchData); |
Bjorn Bringert | 3c50ef6 | 2009-12-09 12:23:12 +0000 | [diff] [blame] | 558 | if (!TextUtils.isEmpty(initialQuery)) { |
Bjorn Bringert | 55f3ac5 | 2010-01-14 11:38:22 +0000 | [diff] [blame] | 559 | intent.putExtra(QUERY, initialQuery); |
Bjorn Bringert | 3c50ef6 | 2009-12-09 12:23:12 +0000 | [diff] [blame] | 560 | } |
| 561 | if (selectInitialQuery) { |
Bjorn Bringert | 55f3ac5 | 2010-01-14 11:38:22 +0000 | [diff] [blame] | 562 | intent.putExtra(EXTRA_SELECT_QUERY, selectInitialQuery); |
Bjorn Bringert | 3c50ef6 | 2009-12-09 12:23:12 +0000 | [diff] [blame] | 563 | } |
Mathew Inwood | 050453e | 2011-10-13 11:00:39 +0100 | [diff] [blame] | 564 | intent.setSourceBounds(sourceBounds); |
Bjorn Bringert | 3c50ef6 | 2009-12-09 12:23:12 +0000 | [diff] [blame] | 565 | try { |
| 566 | if (DBG) Log.d(TAG, "Starting global search: " + intent.toUri(0)); |
| 567 | mContext.startActivity(intent); |
| 568 | } catch (ActivityNotFoundException ex) { |
| 569 | Log.e(TAG, "Global search activity not found: " + globalSearchActivity); |
| 570 | } |
| 571 | } |
| 572 | |
| 573 | /** |
Narayan Kamath | ee69ff4 | 2011-06-28 12:07:18 +0100 | [diff] [blame] | 574 | * Returns a list of installed apps that handle the global search |
| 575 | * intent. |
| 576 | * |
| 577 | * @hide |
| 578 | */ |
| 579 | public List<ResolveInfo> getGlobalSearchActivities() { |
| 580 | try { |
| 581 | return mService.getGlobalSearchActivities(); |
| 582 | } catch (RemoteException ex) { |
| 583 | Log.e(TAG, "getGlobalSearchActivities() failed: " + ex); |
| 584 | return null; |
| 585 | } |
| 586 | } |
| 587 | |
| 588 | /** |
Bjorn Bringert | 3c50ef6 | 2009-12-09 12:23:12 +0000 | [diff] [blame] | 589 | * Gets the name of the global search activity. |
Bjorn Bringert | 3c50ef6 | 2009-12-09 12:23:12 +0000 | [diff] [blame] | 590 | */ |
Bjorn Bringert | 38015f3 | 2010-01-14 14:56:18 +0000 | [diff] [blame] | 591 | public ComponentName getGlobalSearchActivity() { |
Bjorn Bringert | 6cf7a32 | 2010-02-23 13:17:06 +0000 | [diff] [blame] | 592 | try { |
| 593 | return mService.getGlobalSearchActivity(); |
| 594 | } catch (RemoteException ex) { |
| 595 | Log.e(TAG, "getGlobalSearchActivity() failed: " + ex); |
| 596 | return null; |
Bjorn Bringert | 3c50ef6 | 2009-12-09 12:23:12 +0000 | [diff] [blame] | 597 | } |
Bjorn Bringert | 3c50ef6 | 2009-12-09 12:23:12 +0000 | [diff] [blame] | 598 | } |
| 599 | |
| 600 | /** |
Bjorn Bringert | ea125f4 | 2010-02-18 21:57:59 +0000 | [diff] [blame] | 601 | * Gets the name of the web search activity. |
| 602 | * |
| 603 | * @return The name of the default activity for web searches. This activity |
| 604 | * can be used to get web search suggestions. Returns {@code null} if |
| 605 | * there is no default web search activity. |
| 606 | * |
| 607 | * @hide |
| 608 | */ |
| 609 | public ComponentName getWebSearchActivity() { |
Bjorn Bringert | 6cf7a32 | 2010-02-23 13:17:06 +0000 | [diff] [blame] | 610 | try { |
| 611 | return mService.getWebSearchActivity(); |
| 612 | } catch (RemoteException ex) { |
| 613 | Log.e(TAG, "getWebSearchActivity() failed: " + ex); |
Bjorn Bringert | ea125f4 | 2010-02-18 21:57:59 +0000 | [diff] [blame] | 614 | return null; |
| 615 | } |
Bjorn Bringert | ea125f4 | 2010-02-18 21:57:59 +0000 | [diff] [blame] | 616 | } |
| 617 | |
| 618 | /** |
krosaen | d2d6014 | 2009-08-17 08:56:48 -0700 | [diff] [blame] | 619 | * Similar to {@link #startSearch} but actually fires off the search query after invoking |
| 620 | * the search dialog. Made available for testing purposes. |
| 621 | * |
| 622 | * @param query The query to trigger. If empty, request will be ignored. |
| 623 | * @param launchActivity The ComponentName of the activity that has launched this search. |
| 624 | * @param appSearchData An application can insert application-specific |
| 625 | * context here, in order to improve quality or specificity of its own |
| 626 | * searches. This data will be returned with SEARCH intent(s). Null if |
| 627 | * no extra data is required. |
krosaen | d2d6014 | 2009-08-17 08:56:48 -0700 | [diff] [blame] | 628 | * |
| 629 | * @see #startSearch |
| 630 | */ |
| 631 | public void triggerSearch(String query, |
| 632 | ComponentName launchActivity, |
Bjorn Bringert | b782a2f | 2009-10-01 09:57:33 +0100 | [diff] [blame] | 633 | Bundle appSearchData) { |
krosaen | d2d6014 | 2009-08-17 08:56:48 -0700 | [diff] [blame] | 634 | if (!mAssociatedPackage.equals(launchActivity.getPackageName())) { |
| 635 | throw new IllegalArgumentException("invoking app search on a different package " + |
| 636 | "not associated with this search manager"); |
| 637 | } |
| 638 | if (query == null || TextUtils.getTrimmedLength(query) == 0) { |
| 639 | Log.w(TAG, "triggerSearch called with empty query, ignoring."); |
| 640 | return; |
| 641 | } |
Amith Yamasani | e9ce3f0 | 2010-01-25 09:15:50 -0800 | [diff] [blame] | 642 | startSearch(query, false, launchActivity, appSearchData, false); |
| 643 | mSearchDialog.launchQuerySearch(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 644 | } |
| 645 | |
| 646 | /** |
| 647 | * Terminate search UI. |
| 648 | * |
| 649 | * <p>Typically the user will terminate the search UI by launching a |
| 650 | * search or by canceling. This function allows the underlying application |
| 651 | * or activity to cancel the search prematurely (for any reason). |
Amith Yamasani | e678f46 | 2010-09-15 16:13:43 -0700 | [diff] [blame] | 652 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 653 | * <p>This function can be safely called at any time (even if no search is active.) |
| 654 | * |
| 655 | * @see #startSearch |
| 656 | */ |
Bjorn Bringert | 8d17f3f | 2009-06-05 13:22:28 +0100 | [diff] [blame] | 657 | public void stopSearch() { |
Amith Yamasani | e9ce3f0 | 2010-01-25 09:15:50 -0800 | [diff] [blame] | 658 | if (mSearchDialog != null) { |
| 659 | mSearchDialog.cancel(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 660 | } |
| 661 | } |
| 662 | |
| 663 | /** |
Amith Yamasani | e678f46 | 2010-09-15 16:13:43 -0700 | [diff] [blame] | 664 | * Determine if the Search UI is currently displayed. |
| 665 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 666 | * This is provided primarily for application test purposes. |
| 667 | * |
| 668 | * @return Returns true if the search UI is currently displayed. |
Amith Yamasani | e678f46 | 2010-09-15 16:13:43 -0700 | [diff] [blame] | 669 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 670 | * @hide |
| 671 | */ |
Bjorn Bringert | 8d17f3f | 2009-06-05 13:22:28 +0100 | [diff] [blame] | 672 | public boolean isVisible() { |
Amith Yamasani | e9ce3f0 | 2010-01-25 09:15:50 -0800 | [diff] [blame] | 673 | return mSearchDialog == null? false : mSearchDialog.isShowing(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 674 | } |
Bjorn Bringert | 8d17f3f | 2009-06-05 13:22:28 +0100 | [diff] [blame] | 675 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 676 | /** |
Karl Rosaen | a058f02 | 2009-06-01 23:11:44 +0100 | [diff] [blame] | 677 | * See {@link SearchManager#setOnDismissListener} for configuring your activity to monitor |
| 678 | * search UI state. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 679 | */ |
| 680 | public interface OnDismissListener { |
| 681 | /** |
Karl Rosaen | a058f02 | 2009-06-01 23:11:44 +0100 | [diff] [blame] | 682 | * This method will be called when the search UI is dismissed. To make use of it, you must |
| 683 | * implement this method in your activity, and call |
| 684 | * {@link SearchManager#setOnDismissListener} to register it. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 685 | */ |
| 686 | public void onDismiss(); |
| 687 | } |
Amith Yamasani | e678f46 | 2010-09-15 16:13:43 -0700 | [diff] [blame] | 688 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 689 | /** |
Karl Rosaen | a058f02 | 2009-06-01 23:11:44 +0100 | [diff] [blame] | 690 | * See {@link SearchManager#setOnCancelListener} for configuring your activity to monitor |
| 691 | * search UI state. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 692 | */ |
| 693 | public interface OnCancelListener { |
| 694 | /** |
| 695 | * This method will be called when the search UI is canceled. To make use if it, you must |
Karl Rosaen | a058f02 | 2009-06-01 23:11:44 +0100 | [diff] [blame] | 696 | * implement this method in your activity, and call |
| 697 | * {@link SearchManager#setOnCancelListener} to register it. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 698 | */ |
| 699 | public void onCancel(); |
| 700 | } |
| 701 | |
| 702 | /** |
| 703 | * Set or clear the callback that will be invoked whenever the search UI is dismissed. |
Amith Yamasani | e678f46 | 2010-09-15 16:13:43 -0700 | [diff] [blame] | 704 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 705 | * @param listener The {@link OnDismissListener} to use, or null. |
| 706 | */ |
| 707 | public void setOnDismissListener(final OnDismissListener listener) { |
| 708 | mDismissListener = listener; |
| 709 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 710 | |
| 711 | /** |
| 712 | * Set or clear the callback that will be invoked whenever the search UI is canceled. |
Amith Yamasani | e678f46 | 2010-09-15 16:13:43 -0700 | [diff] [blame] | 713 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 714 | * @param listener The {@link OnCancelListener} to use, or null. |
| 715 | */ |
Bjorn Bringert | 8d17f3f | 2009-06-05 13:22:28 +0100 | [diff] [blame] | 716 | public void setOnCancelListener(OnCancelListener listener) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 717 | mCancelListener = listener; |
| 718 | } |
Bjorn Bringert | 8d17f3f | 2009-06-05 13:22:28 +0100 | [diff] [blame] | 719 | |
Bjorn Bringert | 0e01ea4 | 2009-07-08 22:01:29 +0100 | [diff] [blame] | 720 | /** |
| 721 | * @deprecated This method is an obsolete internal implementation detail. Do not use. |
| 722 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 723 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 724 | public void onCancel(DialogInterface dialog) { |
Amith Yamasani | e9ce3f0 | 2010-01-25 09:15:50 -0800 | [diff] [blame] | 725 | if (mCancelListener != null) { |
| 726 | mCancelListener.onCancel(); |
| 727 | } |
Bjorn Bringert | 8d17f3f | 2009-06-05 13:22:28 +0100 | [diff] [blame] | 728 | } |
Bjorn Bringert | 0e01ea4 | 2009-07-08 22:01:29 +0100 | [diff] [blame] | 729 | |
| 730 | /** |
| 731 | * @deprecated This method is an obsolete internal implementation detail. Do not use. |
| 732 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 733 | @Deprecated |
Bjorn Bringert | 8d17f3f | 2009-06-05 13:22:28 +0100 | [diff] [blame] | 734 | public void onDismiss(DialogInterface dialog) { |
Amith Yamasani | e9ce3f0 | 2010-01-25 09:15:50 -0800 | [diff] [blame] | 735 | if (mDismissListener != null) { |
| 736 | mDismissListener.onDismiss(); |
| 737 | } |
Bjorn Bringert | 8d17f3f | 2009-06-05 13:22:28 +0100 | [diff] [blame] | 738 | } |
| 739 | |
| 740 | /** |
Bjorn Bringert | 0408675 | 2010-01-12 15:50:04 +0000 | [diff] [blame] | 741 | * Gets information about a searchable activity. |
| 742 | * |
| 743 | * @param componentName The activity to get searchable information for. |
| 744 | * @return Searchable information, or <code>null</code> if the activity does not |
| 745 | * exist, or is not searchable. |
| 746 | */ |
| 747 | public SearchableInfo getSearchableInfo(ComponentName componentName) { |
| 748 | try { |
Bjorn Bringert | 6cf7a32 | 2010-02-23 13:17:06 +0000 | [diff] [blame] | 749 | return mService.getSearchableInfo(componentName); |
Bjorn Bringert | 8d17f3f | 2009-06-05 13:22:28 +0100 | [diff] [blame] | 750 | } catch (RemoteException ex) { |
| 751 | Log.e(TAG, "getSearchableInfo() failed: " + ex); |
Karl Rosaen | 875d50a | 2009-04-23 19:00:21 -0700 | [diff] [blame] | 752 | return null; |
| 753 | } |
| 754 | } |
Bjorn Bringert | 8d15382 | 2009-06-22 10:31:44 +0100 | [diff] [blame] | 755 | |
Karl Rosaen | 875d50a | 2009-04-23 19:00:21 -0700 | [diff] [blame] | 756 | /** |
Bjorn Bringert | 97325db | 2009-06-22 11:37:03 +0100 | [diff] [blame] | 757 | * Gets a cursor with search suggestions. |
| 758 | * |
| 759 | * @param searchable Information about how to get the suggestions. |
| 760 | * @param query The search text entered (so far). |
| 761 | * @return a cursor with suggestions, or <code>null</null> the suggestion query failed. |
| 762 | * |
| 763 | * @hide because SearchableInfo is not part of the API. |
| 764 | */ |
| 765 | public Cursor getSuggestions(SearchableInfo searchable, String query) { |
Bjorn Bringert | 3fc7c67 | 2009-09-28 20:11:52 +0100 | [diff] [blame] | 766 | return getSuggestions(searchable, query, -1); |
| 767 | } |
| 768 | |
| 769 | /** |
| 770 | * Gets a cursor with search suggestions. |
| 771 | * |
| 772 | * @param searchable Information about how to get the suggestions. |
| 773 | * @param query The search text entered (so far). |
| 774 | * @param limit The query limit to pass to the suggestion provider. This is advisory, |
| 775 | * the returned cursor may contain more rows. Pass {@code -1} for no limit. |
| 776 | * @return a cursor with suggestions, or <code>null</null> the suggestion query failed. |
| 777 | * |
| 778 | * @hide because SearchableInfo is not part of the API. |
| 779 | */ |
| 780 | public Cursor getSuggestions(SearchableInfo searchable, String query, int limit) { |
Karl Rosaen | 875d50a | 2009-04-23 19:00:21 -0700 | [diff] [blame] | 781 | if (searchable == null) { |
| 782 | return null; |
| 783 | } |
| 784 | |
| 785 | String authority = searchable.getSuggestAuthority(); |
| 786 | if (authority == null) { |
| 787 | return null; |
| 788 | } |
| 789 | |
| 790 | Uri.Builder uriBuilder = new Uri.Builder() |
| 791 | .scheme(ContentResolver.SCHEME_CONTENT) |
Bjorn Bringert | 3fc7c67 | 2009-09-28 20:11:52 +0100 | [diff] [blame] | 792 | .authority(authority) |
| 793 | .query("") // TODO: Remove, workaround for a bug in Uri.writeToParcel() |
| 794 | .fragment(""); // TODO: Remove, workaround for a bug in Uri.writeToParcel() |
Karl Rosaen | 875d50a | 2009-04-23 19:00:21 -0700 | [diff] [blame] | 795 | |
| 796 | // if content path provided, insert it now |
| 797 | final String contentPath = searchable.getSuggestPath(); |
| 798 | if (contentPath != null) { |
| 799 | uriBuilder.appendEncodedPath(contentPath); |
| 800 | } |
| 801 | |
Bjorn Bringert | 3fc7c67 | 2009-09-28 20:11:52 +0100 | [diff] [blame] | 802 | // append standard suggestion query path |
Karl Rosaen | 875d50a | 2009-04-23 19:00:21 -0700 | [diff] [blame] | 803 | uriBuilder.appendPath(SearchManager.SUGGEST_URI_PATH_QUERY); |
| 804 | |
| 805 | // get the query selection, may be null |
| 806 | String selection = searchable.getSuggestSelection(); |
| 807 | // inject query, either as selection args or inline |
| 808 | String[] selArgs = null; |
| 809 | if (selection != null) { // use selection if provided |
| 810 | selArgs = new String[] { query }; |
| 811 | } else { // no selection, use REST pattern |
| 812 | uriBuilder.appendPath(query); |
| 813 | } |
| 814 | |
Bjorn Bringert | 3fc7c67 | 2009-09-28 20:11:52 +0100 | [diff] [blame] | 815 | if (limit > 0) { |
| 816 | uriBuilder.appendQueryParameter(SUGGEST_PARAMETER_LIMIT, String.valueOf(limit)); |
| 817 | } |
| 818 | |
| 819 | Uri uri = uriBuilder.build(); |
Karl Rosaen | 875d50a | 2009-04-23 19:00:21 -0700 | [diff] [blame] | 820 | |
| 821 | // finally, make the query |
Bjorn Bringert | 8d15382 | 2009-06-22 10:31:44 +0100 | [diff] [blame] | 822 | return mContext.getContentResolver().query(uri, null, selection, selArgs, null); |
Karl Rosaen | 875d50a | 2009-04-23 19:00:21 -0700 | [diff] [blame] | 823 | } |
Amith Yamasani | e678f46 | 2010-09-15 16:13:43 -0700 | [diff] [blame] | 824 | |
Bjorn Bringert | 6d72e02 | 2009-04-29 14:56:12 +0100 | [diff] [blame] | 825 | /** |
| 826 | * Returns a list of the searchable activities that can be included in global search. |
Amith Yamasani | e678f46 | 2010-09-15 16:13:43 -0700 | [diff] [blame] | 827 | * |
Bjorn Bringert | 6d72e02 | 2009-04-29 14:56:12 +0100 | [diff] [blame] | 828 | * @return a list containing searchable information for all searchable activities |
Bjorn Bringert | 13107bb | 2009-12-07 10:41:24 +0000 | [diff] [blame] | 829 | * that have the <code>android:includeInGlobalSearch</code> attribute set |
| 830 | * in their searchable meta-data. |
Bjorn Bringert | 6d72e02 | 2009-04-29 14:56:12 +0100 | [diff] [blame] | 831 | */ |
Bjorn Bringert | 8d15382 | 2009-06-22 10:31:44 +0100 | [diff] [blame] | 832 | public List<SearchableInfo> getSearchablesInGlobalSearch() { |
Bjorn Bringert | 6d72e02 | 2009-04-29 14:56:12 +0100 | [diff] [blame] | 833 | try { |
Bjorn Bringert | 8d15382 | 2009-06-22 10:31:44 +0100 | [diff] [blame] | 834 | return mService.getSearchablesInGlobalSearch(); |
Bjorn Bringert | 6d72e02 | 2009-04-29 14:56:12 +0100 | [diff] [blame] | 835 | } catch (RemoteException e) { |
Bjorn Bringert | 8d17f3f | 2009-06-05 13:22:28 +0100 | [diff] [blame] | 836 | Log.e(TAG, "getSearchablesInGlobalSearch() failed: " + e); |
Bjorn Bringert | 6d72e02 | 2009-04-29 14:56:12 +0100 | [diff] [blame] | 837 | return null; |
| 838 | } |
| 839 | } |
Satish Sampath | f9acde2 | 2009-06-04 11:51:17 +0100 | [diff] [blame] | 840 | |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 841 | /** |
Jim Miller | 45308b1 | 2012-06-18 19:23:39 -0700 | [diff] [blame] | 842 | * Gets an intent for launching installed assistant activity, or null if not available. |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 843 | * @return The assist intent. |
| 844 | * |
| 845 | * @hide |
| 846 | */ |
Dianne Hackborn | f9c5e0f | 2013-01-23 14:39:13 -0800 | [diff] [blame] | 847 | public Intent getAssistIntent(Context context, boolean inclContext) { |
| 848 | return getAssistIntent(context, inclContext, UserHandle.myUserId()); |
Amith Yamasani | c1d07a4 | 2012-08-14 09:32:02 -0700 | [diff] [blame] | 849 | } |
| 850 | |
| 851 | /** |
| 852 | * Gets an intent for launching installed assistant activity, or null if not available. |
| 853 | * @return The assist intent. |
| 854 | * |
| 855 | * @hide |
| 856 | */ |
Dianne Hackborn | f9c5e0f | 2013-01-23 14:39:13 -0800 | [diff] [blame] | 857 | public Intent getAssistIntent(Context context, boolean inclContext, int userHandle) { |
Amith Yamasani | c1d07a4 | 2012-08-14 09:32:02 -0700 | [diff] [blame] | 858 | try { |
John Spurlock | 43d8451 | 2012-11-09 10:27:33 -0500 | [diff] [blame] | 859 | if (mService == null) { |
| 860 | return null; |
| 861 | } |
Amith Yamasani | c1d07a4 | 2012-08-14 09:32:02 -0700 | [diff] [blame] | 862 | ComponentName comp = mService.getAssistIntent(userHandle); |
| 863 | if (comp == null) { |
| 864 | return null; |
| 865 | } |
| 866 | Intent intent = new Intent(Intent.ACTION_ASSIST); |
| 867 | intent.setComponent(comp); |
Dianne Hackborn | f9c5e0f | 2013-01-23 14:39:13 -0800 | [diff] [blame] | 868 | if (inclContext) { |
| 869 | IActivityManager am = ActivityManagerNative.getDefault(); |
Adam Skory | dfc7fd7 | 2013-08-05 19:23:41 -0700 | [diff] [blame] | 870 | Bundle extras = am.getAssistContextExtras(0); |
Dianne Hackborn | f9c5e0f | 2013-01-23 14:39:13 -0800 | [diff] [blame] | 871 | if (extras != null) { |
| 872 | intent.replaceExtras(extras); |
| 873 | } |
| 874 | } |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 875 | return intent; |
Amith Yamasani | c1d07a4 | 2012-08-14 09:32:02 -0700 | [diff] [blame] | 876 | } catch (RemoteException re) { |
| 877 | Log.e(TAG, "getAssistIntent() failed: " + re); |
| 878 | return null; |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 879 | } |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 880 | } |
Amith Yamasani | e9ce3f0 | 2010-01-25 09:15:50 -0800 | [diff] [blame] | 881 | } |