141b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau/* 241b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * Copyright (C) 2010 The Android Open Source Project 341b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * 441b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * Licensed under the Apache License, Version 2.0 (the "License"); 541b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * you may not use this file except in compliance with the License. 641b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * You may obtain a copy of the License at 741b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * 841b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * http://www.apache.org/licenses/LICENSE-2.0 941b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * 1041b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * Unless required by applicable law or agreed to in writing, software 1141b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * distributed under the License is distributed on an "AS IS" BASIS, 1241b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1341b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * See the License for the specific language governing permissions and 1441b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * limitations under the License. 1541b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau */ 1641b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau 1741b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeaupackage android.speech; 1841b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau 192ffa625a2ad57614e0a963899669ee542d1ca988Valentin Kravtsovimport android.os.Bundle; 202ffa625a2ad57614e0a963899669ee542d1ca988Valentin Kravtsov 2141b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeauimport java.util.ArrayList; 2241b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau 2341b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau/** 2441b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * Constants for intents related to showing speech recognition results. 2541b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * 2641b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * These constants should not be needed for normal utilization of speech recognition. They 2741b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * would only be called if you wanted to trigger a view of voice search results in your 2841b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * application, or implemented if you wanted to offer a different view for voice search results 2941b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * with your application. 3041b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * 3141b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * The standard behavior here for someone receiving an {@link #ACTION_VOICE_SEARCH_RESULTS} is to 3241b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * first retrieve the list of {@link #EXTRA_VOICE_SEARCH_RESULT_STRINGS}, and use any provided 3341b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * HTML for that result in {@link #EXTRA_VOICE_SEARCH_RESULT_HTML}, if available, to display 3441b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * the search results. If that is not available, then the corresponding url for that result in 3541b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * {@link #EXTRA_VOICE_SEARCH_RESULT_URLS} should be used. And if even that is not available, 3641b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * then a search url should be constructed from the actual recognition result string. 3741b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau */ 3841b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeaupublic class RecognizerResultsIntent { 3941b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau private RecognizerResultsIntent() { 4041b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau // Not for instantiating. 4141b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau } 4241b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau 4341b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau /** 4441b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * Intent that can be sent by implementations of voice search to display the results of 4541b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * a search in, for example, a web browser. 4641b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * 4741b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * This intent should always be accompanied by at least 4841b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * {@link #EXTRA_VOICE_SEARCH_RESULT_STRINGS}, and optionally but recommended, 4941b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * {@link #EXTRA_VOICE_SEARCH_RESULT_URLS}, and sometimes 50f9271c8b7dfafecef6747c81aa1c9038ab51d274Mike LeBeau * {@link #EXTRA_VOICE_SEARCH_RESULT_HTML} and 51f9271c8b7dfafecef6747c81aa1c9038ab51d274Mike LeBeau * {@link #EXTRA_VOICE_SEARCH_RESULT_HTML_BASE_URLS}. 52f9271c8b7dfafecef6747c81aa1c9038ab51d274Mike LeBeau * 53f9271c8b7dfafecef6747c81aa1c9038ab51d274Mike LeBeau * These are parallel arrays, where a recognition result string at index N of 54f9271c8b7dfafecef6747c81aa1c9038ab51d274Mike LeBeau * {@link #EXTRA_VOICE_SEARCH_RESULT_STRINGS} should be accompanied by a url to use for 55f9271c8b7dfafecef6747c81aa1c9038ab51d274Mike LeBeau * searching based on that string at index N of {@link #EXTRA_VOICE_SEARCH_RESULT_URLS}, 56f9271c8b7dfafecef6747c81aa1c9038ab51d274Mike LeBeau * and, possibly, the full html to display for that result at index N of 57f9271c8b7dfafecef6747c81aa1c9038ab51d274Mike LeBeau * {@link #EXTRA_VOICE_SEARCH_RESULT_HTML}. If full html is provided, a base url (or 58f9271c8b7dfafecef6747c81aa1c9038ab51d274Mike LeBeau * list of base urls) should be provided with {@link #EXTRA_VOICE_SEARCH_RESULT_HTML_BASE_URLS}. 5941b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau */ 6041b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau public static final String ACTION_VOICE_SEARCH_RESULTS = 6141b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau "android.speech.action.VOICE_SEARCH_RESULTS"; 6241b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau 6341b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau /** 6441b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * The key to an extra {@link ArrayList} of {@link String}s that contains the list of 6541b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * recognition alternates from voice search, in order from highest to lowest confidence. 6641b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau */ 6741b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau public static final String EXTRA_VOICE_SEARCH_RESULT_STRINGS = 6841b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau "android.speech.extras.VOICE_SEARCH_RESULT_STRINGS"; 6941b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau 7041b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau /** 7141b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * The key to an extra {@link ArrayList} of {@link String}s that contains the search urls 7241b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * to use, if available, for the recognition alternates provided in 7341b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * {@link #EXTRA_VOICE_SEARCH_RESULT_STRINGS}. This list should always be the same size as the 7441b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * one provided in {@link #EXTRA_VOICE_SEARCH_RESULT_STRINGS} - if a result cannot provide a 7541b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * search url, that entry in this ArrayList should be <code>null</code>, and the implementor of 7641b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * {@link #ACTION_VOICE_SEARCH_RESULTS} should execute a search of its own choosing, 7741b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * based on the recognition result string. 7841b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau */ 7941b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau public static final String EXTRA_VOICE_SEARCH_RESULT_URLS = 8041b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau "android.speech.extras.VOICE_SEARCH_RESULT_URLS"; 8141b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau 8241b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau /** 8341b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * The key to an extra {@link ArrayList} of {@link String}s that contains the html content to 8441b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * use, if available, for the recognition alternates provided in 8541b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * {@link #EXTRA_VOICE_SEARCH_RESULT_STRINGS}. This list should always be the same size as the 8641b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * one provided in {@link #EXTRA_VOICE_SEARCH_RESULT_STRINGS} - if a result cannot provide 8741b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * html, that entry in this list should be <code>null</code>, and the implementor of 8841b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * {@link #ACTION_VOICE_SEARCH_RESULTS} should back off to the corresponding url provided in 8941b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * {@link #EXTRA_VOICE_SEARCH_RESULT_URLS}, if available, or else should execute a search of 9041b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * its own choosing, based on the recognition result string. 9141b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * 92dcfefb5db31383e557804b81e5e36f4584af7c22Mike LeBeau * Currently this html content should be expected in the form of a uri with scheme 93dcfefb5db31383e557804b81e5e36f4584af7c22Mike LeBeau * {@link #URI_SCHEME_INLINE} for the Browser. In the future this may change to a "content://" 94dcfefb5db31383e557804b81e5e36f4584af7c22Mike LeBeau * uri or some other identifier. Anyone who reads this extra should confirm that a result is 95dcfefb5db31383e557804b81e5e36f4584af7c22Mike LeBeau * in fact an "inline:" uri and back off to the urls or strings gracefully if it is not, thus 96dcfefb5db31383e557804b81e5e36f4584af7c22Mike LeBeau * maintaining future backwards compatibility if this changes. 9741b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau */ 9841b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau public static final String EXTRA_VOICE_SEARCH_RESULT_HTML = 9941b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau "android.speech.extras.VOICE_SEARCH_RESULT_HTML"; 100f9271c8b7dfafecef6747c81aa1c9038ab51d274Mike LeBeau 101f9271c8b7dfafecef6747c81aa1c9038ab51d274Mike LeBeau /** 102f9271c8b7dfafecef6747c81aa1c9038ab51d274Mike LeBeau * The key to an extra {@link ArrayList} of {@link String}s that contains the base url to 103f9271c8b7dfafecef6747c81aa1c9038ab51d274Mike LeBeau * assume when interpreting html provided in {@link #EXTRA_VOICE_SEARCH_RESULT_HTML}. 104f9271c8b7dfafecef6747c81aa1c9038ab51d274Mike LeBeau * 105f9271c8b7dfafecef6747c81aa1c9038ab51d274Mike LeBeau * A list of size 1 may be provided to apply the same base url to all html results. 106f9271c8b7dfafecef6747c81aa1c9038ab51d274Mike LeBeau * A list of the same size as {@link #EXTRA_VOICE_SEARCH_RESULT_STRINGS} may be provided 107f9271c8b7dfafecef6747c81aa1c9038ab51d274Mike LeBeau * to apply different base urls to each different html result in the 108f9271c8b7dfafecef6747c81aa1c9038ab51d274Mike LeBeau * {@link #EXTRA_VOICE_SEARCH_RESULT_HTML} list. 109f9271c8b7dfafecef6747c81aa1c9038ab51d274Mike LeBeau */ 110f9271c8b7dfafecef6747c81aa1c9038ab51d274Mike LeBeau public static final String EXTRA_VOICE_SEARCH_RESULT_HTML_BASE_URLS = 111f9271c8b7dfafecef6747c81aa1c9038ab51d274Mike LeBeau "android.speech.extras.VOICE_SEARCH_RESULT_HTML_BASE_URLS"; 1122ffa625a2ad57614e0a963899669ee542d1ca988Valentin Kravtsov 1132ffa625a2ad57614e0a963899669ee542d1ca988Valentin Kravtsov /** 1142ffa625a2ad57614e0a963899669ee542d1ca988Valentin Kravtsov * The key to an extra {@link ArrayList} of {@link Bundle}s that contains key/value pairs. 1152ffa625a2ad57614e0a963899669ee542d1ca988Valentin Kravtsov * All the values and the keys are {@link String}s. Each key/value pair represents an extra HTTP 1162ffa625a2ad57614e0a963899669ee542d1ca988Valentin Kravtsov * header. The keys can't be the standard HTTP headers as they are set by the WebView. 1172ffa625a2ad57614e0a963899669ee542d1ca988Valentin Kravtsov * 118eba0f753b26bfc9a4a39b9296878581b5e6704a0Mike LeBeau * A list of size 1 may be provided to apply the same HTTP headers to all web results. A 119eba0f753b26bfc9a4a39b9296878581b5e6704a0Mike LeBeau * list of the same size as {@link #EXTRA_VOICE_SEARCH_RESULT_STRINGS} may be provided to 120eba0f753b26bfc9a4a39b9296878581b5e6704a0Mike LeBeau * apply different HTTP headers to each different web result in the list. These headers will 121eba0f753b26bfc9a4a39b9296878581b5e6704a0Mike LeBeau * only be used in the case that the url for a particular web result (from 122eba0f753b26bfc9a4a39b9296878581b5e6704a0Mike LeBeau * {@link #EXTRA_VOICE_SEARCH_RESULT_URLS}) is loaded. 1232ffa625a2ad57614e0a963899669ee542d1ca988Valentin Kravtsov */ 1242ffa625a2ad57614e0a963899669ee542d1ca988Valentin Kravtsov public static final String EXTRA_VOICE_SEARCH_RESULT_HTTP_HEADERS = 1252ffa625a2ad57614e0a963899669ee542d1ca988Valentin Kravtsov "android.speech.extras.EXTRA_VOICE_SEARCH_RESULT_HTTP_HEADERS"; 1262ffa625a2ad57614e0a963899669ee542d1ca988Valentin Kravtsov 127dcfefb5db31383e557804b81e5e36f4584af7c22Mike LeBeau /** 128dcfefb5db31383e557804b81e5e36f4584af7c22Mike LeBeau * The scheme used currently for html content in {@link #EXTRA_VOICE_SEARCH_RESULT_HTML}. 12952af3a4f9a1f13ea3b19a7d2f2ee07c733abef74Mike LeBeau * Note that this should only be used in tandem with this particular extra; it should 13052af3a4f9a1f13ea3b19a7d2f2ee07c733abef74Mike LeBeau * NOT be used for generic URIs such as those found in the data field of an Intent. 131dcfefb5db31383e557804b81e5e36f4584af7c22Mike LeBeau */ 132dcfefb5db31383e557804b81e5e36f4584af7c22Mike LeBeau public static final String URI_SCHEME_INLINE = "inline"; 13341b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau} 134