RecognizerResultsIntent.java revision dcfefb5db31383e557804b81e5e36f4584af7c22
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 1941b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeauimport java.util.ArrayList; 2041b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau 2141b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau/** 2241b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * Constants for intents related to showing speech recognition results. 2341b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * 2441b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * These constants should not be needed for normal utilization of speech recognition. They 2541b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * would only be called if you wanted to trigger a view of voice search results in your 2641b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * application, or implemented if you wanted to offer a different view for voice search results 2741b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * with your application. 2841b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * 2941b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * The standard behavior here for someone receiving an {@link #ACTION_VOICE_SEARCH_RESULTS} is to 3041b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * first retrieve the list of {@link #EXTRA_VOICE_SEARCH_RESULT_STRINGS}, and use any provided 3141b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * HTML for that result in {@link #EXTRA_VOICE_SEARCH_RESULT_HTML}, if available, to display 3241b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * the search results. If that is not available, then the corresponding url for that result in 3341b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * {@link #EXTRA_VOICE_SEARCH_RESULT_URLS} should be used. And if even that is not available, 3441b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * then a search url should be constructed from the actual recognition result string. 3541b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * 3641b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * @hide for making public in a later release 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 * @hide for making public in a later release 6141b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau */ 6241b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau public static final String ACTION_VOICE_SEARCH_RESULTS = 6341b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau "android.speech.action.VOICE_SEARCH_RESULTS"; 6441b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau 6541b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau /** 6641b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * The key to an extra {@link ArrayList} of {@link String}s that contains the list of 6741b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * recognition alternates from voice search, in order from highest to lowest confidence. 6841b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * 6941b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * @hide for making public in a later release 7041b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau */ 7141b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau public static final String EXTRA_VOICE_SEARCH_RESULT_STRINGS = 7241b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau "android.speech.extras.VOICE_SEARCH_RESULT_STRINGS"; 7341b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau 7441b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau /** 7541b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * The key to an extra {@link ArrayList} of {@link String}s that contains the search urls 7641b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * to use, if available, for the recognition alternates provided in 7741b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * {@link #EXTRA_VOICE_SEARCH_RESULT_STRINGS}. This list should always be the same size as the 7841b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * one provided in {@link #EXTRA_VOICE_SEARCH_RESULT_STRINGS} - if a result cannot provide a 7941b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * search url, that entry in this ArrayList should be <code>null</code>, and the implementor of 8041b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * {@link #ACTION_VOICE_SEARCH_RESULTS} should execute a search of its own choosing, 8141b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * based on the recognition result string. 8241b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * 8341b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * @hide for making public in a later release 8441b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau */ 8541b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau public static final String EXTRA_VOICE_SEARCH_RESULT_URLS = 8641b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau "android.speech.extras.VOICE_SEARCH_RESULT_URLS"; 8741b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau 8841b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau /** 8941b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * The key to an extra {@link ArrayList} of {@link String}s that contains the html content to 9041b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * use, if available, for the recognition alternates provided in 9141b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * {@link #EXTRA_VOICE_SEARCH_RESULT_STRINGS}. This list should always be the same size as the 9241b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * one provided in {@link #EXTRA_VOICE_SEARCH_RESULT_STRINGS} - if a result cannot provide 9341b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * html, that entry in this list should be <code>null</code>, and the implementor of 9441b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * {@link #ACTION_VOICE_SEARCH_RESULTS} should back off to the corresponding url provided in 9541b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * {@link #EXTRA_VOICE_SEARCH_RESULT_URLS}, if available, or else should execute a search of 9641b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * its own choosing, based on the recognition result string. 9741b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * 98dcfefb5db31383e557804b81e5e36f4584af7c22Mike LeBeau * Currently this html content should be expected in the form of a uri with scheme 99dcfefb5db31383e557804b81e5e36f4584af7c22Mike LeBeau * {@link #URI_SCHEME_INLINE} for the Browser. In the future this may change to a "content://" 100dcfefb5db31383e557804b81e5e36f4584af7c22Mike LeBeau * uri or some other identifier. Anyone who reads this extra should confirm that a result is 101dcfefb5db31383e557804b81e5e36f4584af7c22Mike LeBeau * in fact an "inline:" uri and back off to the urls or strings gracefully if it is not, thus 102dcfefb5db31383e557804b81e5e36f4584af7c22Mike LeBeau * maintaining future backwards compatibility if this changes. 10341b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * 10441b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau * @hide not to be exposed immediately as the implementation details may change 10541b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau */ 10641b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau public static final String EXTRA_VOICE_SEARCH_RESULT_HTML = 10741b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau "android.speech.extras.VOICE_SEARCH_RESULT_HTML"; 108f9271c8b7dfafecef6747c81aa1c9038ab51d274Mike LeBeau 109f9271c8b7dfafecef6747c81aa1c9038ab51d274Mike LeBeau /** 110f9271c8b7dfafecef6747c81aa1c9038ab51d274Mike LeBeau * The key to an extra {@link ArrayList} of {@link String}s that contains the base url to 111f9271c8b7dfafecef6747c81aa1c9038ab51d274Mike LeBeau * assume when interpreting html provided in {@link #EXTRA_VOICE_SEARCH_RESULT_HTML}. 112f9271c8b7dfafecef6747c81aa1c9038ab51d274Mike LeBeau * 113f9271c8b7dfafecef6747c81aa1c9038ab51d274Mike LeBeau * A list of size 1 may be provided to apply the same base url to all html results. 114f9271c8b7dfafecef6747c81aa1c9038ab51d274Mike LeBeau * A list of the same size as {@link #EXTRA_VOICE_SEARCH_RESULT_STRINGS} may be provided 115f9271c8b7dfafecef6747c81aa1c9038ab51d274Mike LeBeau * to apply different base urls to each different html result in the 116f9271c8b7dfafecef6747c81aa1c9038ab51d274Mike LeBeau * {@link #EXTRA_VOICE_SEARCH_RESULT_HTML} list. 117f9271c8b7dfafecef6747c81aa1c9038ab51d274Mike LeBeau * 118f9271c8b7dfafecef6747c81aa1c9038ab51d274Mike LeBeau * @hide not to be exposed immediately as the implementation details may change 119f9271c8b7dfafecef6747c81aa1c9038ab51d274Mike LeBeau */ 120f9271c8b7dfafecef6747c81aa1c9038ab51d274Mike LeBeau public static final String EXTRA_VOICE_SEARCH_RESULT_HTML_BASE_URLS = 121f9271c8b7dfafecef6747c81aa1c9038ab51d274Mike LeBeau "android.speech.extras.VOICE_SEARCH_RESULT_HTML_BASE_URLS"; 122dcfefb5db31383e557804b81e5e36f4584af7c22Mike LeBeau 123dcfefb5db31383e557804b81e5e36f4584af7c22Mike LeBeau /** 124dcfefb5db31383e557804b81e5e36f4584af7c22Mike LeBeau * The scheme used currently for html content in {@link #EXTRA_VOICE_SEARCH_RESULT_HTML}. 125dcfefb5db31383e557804b81e5e36f4584af7c22Mike LeBeau * 126dcfefb5db31383e557804b81e5e36f4584af7c22Mike LeBeau * @hide not to be exposed immediately as the implementation details may change 127dcfefb5db31383e557804b81e5e36f4584af7c22Mike LeBeau */ 128dcfefb5db31383e557804b81e5e36f4584af7c22Mike LeBeau public static final String URI_SCHEME_INLINE = "inline"; 12941b14e8ff7a1774fc69dfcf1261f87e50dd55a03Mike LeBeau} 130