am 38cb6197: am 2a5d9f9b: Fix bug 2553592 API REVIEW: android.speech Change 1 of 4 Notes from API Council review: Rename RecognitionManager to SpeechRecognizer
Merge commit '38cb619770cf7b4207f464edc4839c79c03ad372' into kraken * commit '38cb619770cf7b4207f464edc4839c79c03ad372': Fix bug 2553592 API REVIEW: android.speech
This commit is contained in:
438
api/current.xml
438
api/current.xml
@@ -138315,225 +138315,6 @@
|
|||||||
</parameter>
|
</parameter>
|
||||||
</method>
|
</method>
|
||||||
</interface>
|
</interface>
|
||||||
<class name="RecognitionManager"
|
|
||||||
extends="java.lang.Object"
|
|
||||||
abstract="false"
|
|
||||||
static="false"
|
|
||||||
final="false"
|
|
||||||
deprecated="not deprecated"
|
|
||||||
visibility="public"
|
|
||||||
>
|
|
||||||
<method name="cancel"
|
|
||||||
return="void"
|
|
||||||
abstract="false"
|
|
||||||
native="false"
|
|
||||||
synchronized="false"
|
|
||||||
static="false"
|
|
||||||
final="false"
|
|
||||||
deprecated="not deprecated"
|
|
||||||
visibility="public"
|
|
||||||
>
|
|
||||||
</method>
|
|
||||||
<method name="createRecognitionManager"
|
|
||||||
return="android.speech.RecognitionManager"
|
|
||||||
abstract="false"
|
|
||||||
native="false"
|
|
||||||
synchronized="false"
|
|
||||||
static="true"
|
|
||||||
final="false"
|
|
||||||
deprecated="not deprecated"
|
|
||||||
visibility="public"
|
|
||||||
>
|
|
||||||
<parameter name="context" type="android.content.Context">
|
|
||||||
</parameter>
|
|
||||||
</method>
|
|
||||||
<method name="createRecognitionManager"
|
|
||||||
return="android.speech.RecognitionManager"
|
|
||||||
abstract="false"
|
|
||||||
native="false"
|
|
||||||
synchronized="false"
|
|
||||||
static="true"
|
|
||||||
final="false"
|
|
||||||
deprecated="not deprecated"
|
|
||||||
visibility="public"
|
|
||||||
>
|
|
||||||
<parameter name="context" type="android.content.Context">
|
|
||||||
</parameter>
|
|
||||||
<parameter name="serviceComponent" type="android.content.ComponentName">
|
|
||||||
</parameter>
|
|
||||||
</method>
|
|
||||||
<method name="destroy"
|
|
||||||
return="void"
|
|
||||||
abstract="false"
|
|
||||||
native="false"
|
|
||||||
synchronized="false"
|
|
||||||
static="false"
|
|
||||||
final="false"
|
|
||||||
deprecated="not deprecated"
|
|
||||||
visibility="public"
|
|
||||||
>
|
|
||||||
</method>
|
|
||||||
<method name="isRecognitionAvailable"
|
|
||||||
return="boolean"
|
|
||||||
abstract="false"
|
|
||||||
native="false"
|
|
||||||
synchronized="false"
|
|
||||||
static="true"
|
|
||||||
final="false"
|
|
||||||
deprecated="not deprecated"
|
|
||||||
visibility="public"
|
|
||||||
>
|
|
||||||
<parameter name="context" type="android.content.Context">
|
|
||||||
</parameter>
|
|
||||||
</method>
|
|
||||||
<method name="setRecognitionListener"
|
|
||||||
return="void"
|
|
||||||
abstract="false"
|
|
||||||
native="false"
|
|
||||||
synchronized="false"
|
|
||||||
static="false"
|
|
||||||
final="false"
|
|
||||||
deprecated="not deprecated"
|
|
||||||
visibility="public"
|
|
||||||
>
|
|
||||||
<parameter name="listener" type="android.speech.RecognitionListener">
|
|
||||||
</parameter>
|
|
||||||
</method>
|
|
||||||
<method name="startListening"
|
|
||||||
return="void"
|
|
||||||
abstract="false"
|
|
||||||
native="false"
|
|
||||||
synchronized="false"
|
|
||||||
static="false"
|
|
||||||
final="false"
|
|
||||||
deprecated="not deprecated"
|
|
||||||
visibility="public"
|
|
||||||
>
|
|
||||||
<parameter name="recognizerIntent" type="android.content.Intent">
|
|
||||||
</parameter>
|
|
||||||
</method>
|
|
||||||
<method name="stopListening"
|
|
||||||
return="void"
|
|
||||||
abstract="false"
|
|
||||||
native="false"
|
|
||||||
synchronized="false"
|
|
||||||
static="false"
|
|
||||||
final="false"
|
|
||||||
deprecated="not deprecated"
|
|
||||||
visibility="public"
|
|
||||||
>
|
|
||||||
</method>
|
|
||||||
<field name="ERROR_AUDIO"
|
|
||||||
type="int"
|
|
||||||
transient="false"
|
|
||||||
volatile="false"
|
|
||||||
value="3"
|
|
||||||
static="true"
|
|
||||||
final="true"
|
|
||||||
deprecated="not deprecated"
|
|
||||||
visibility="public"
|
|
||||||
>
|
|
||||||
</field>
|
|
||||||
<field name="ERROR_CLIENT"
|
|
||||||
type="int"
|
|
||||||
transient="false"
|
|
||||||
volatile="false"
|
|
||||||
value="5"
|
|
||||||
static="true"
|
|
||||||
final="true"
|
|
||||||
deprecated="not deprecated"
|
|
||||||
visibility="public"
|
|
||||||
>
|
|
||||||
</field>
|
|
||||||
<field name="ERROR_INSUFFICIENT_PERMISSIONS"
|
|
||||||
type="int"
|
|
||||||
transient="false"
|
|
||||||
volatile="false"
|
|
||||||
value="9"
|
|
||||||
static="true"
|
|
||||||
final="true"
|
|
||||||
deprecated="not deprecated"
|
|
||||||
visibility="public"
|
|
||||||
>
|
|
||||||
</field>
|
|
||||||
<field name="ERROR_NETWORK"
|
|
||||||
type="int"
|
|
||||||
transient="false"
|
|
||||||
volatile="false"
|
|
||||||
value="2"
|
|
||||||
static="true"
|
|
||||||
final="true"
|
|
||||||
deprecated="not deprecated"
|
|
||||||
visibility="public"
|
|
||||||
>
|
|
||||||
</field>
|
|
||||||
<field name="ERROR_NETWORK_TIMEOUT"
|
|
||||||
type="int"
|
|
||||||
transient="false"
|
|
||||||
volatile="false"
|
|
||||||
value="1"
|
|
||||||
static="true"
|
|
||||||
final="true"
|
|
||||||
deprecated="not deprecated"
|
|
||||||
visibility="public"
|
|
||||||
>
|
|
||||||
</field>
|
|
||||||
<field name="ERROR_NO_MATCH"
|
|
||||||
type="int"
|
|
||||||
transient="false"
|
|
||||||
volatile="false"
|
|
||||||
value="7"
|
|
||||||
static="true"
|
|
||||||
final="true"
|
|
||||||
deprecated="not deprecated"
|
|
||||||
visibility="public"
|
|
||||||
>
|
|
||||||
</field>
|
|
||||||
<field name="ERROR_RECOGNIZER_BUSY"
|
|
||||||
type="int"
|
|
||||||
transient="false"
|
|
||||||
volatile="false"
|
|
||||||
value="8"
|
|
||||||
static="true"
|
|
||||||
final="true"
|
|
||||||
deprecated="not deprecated"
|
|
||||||
visibility="public"
|
|
||||||
>
|
|
||||||
</field>
|
|
||||||
<field name="ERROR_SERVER"
|
|
||||||
type="int"
|
|
||||||
transient="false"
|
|
||||||
volatile="false"
|
|
||||||
value="4"
|
|
||||||
static="true"
|
|
||||||
final="true"
|
|
||||||
deprecated="not deprecated"
|
|
||||||
visibility="public"
|
|
||||||
>
|
|
||||||
</field>
|
|
||||||
<field name="ERROR_SPEECH_TIMEOUT"
|
|
||||||
type="int"
|
|
||||||
transient="false"
|
|
||||||
volatile="false"
|
|
||||||
value="6"
|
|
||||||
static="true"
|
|
||||||
final="true"
|
|
||||||
deprecated="not deprecated"
|
|
||||||
visibility="public"
|
|
||||||
>
|
|
||||||
</field>
|
|
||||||
<field name="RESULTS_RECOGNITION"
|
|
||||||
type="java.lang.String"
|
|
||||||
transient="false"
|
|
||||||
volatile="false"
|
|
||||||
value=""results_recognition""
|
|
||||||
static="true"
|
|
||||||
final="true"
|
|
||||||
deprecated="not deprecated"
|
|
||||||
visibility="public"
|
|
||||||
>
|
|
||||||
</field>
|
|
||||||
</class>
|
|
||||||
<class name="RecognitionService"
|
<class name="RecognitionService"
|
||||||
extends="android.app.Service"
|
extends="android.app.Service"
|
||||||
abstract="true"
|
abstract="true"
|
||||||
@@ -139060,6 +138841,225 @@
|
|||||||
>
|
>
|
||||||
</field>
|
</field>
|
||||||
</class>
|
</class>
|
||||||
|
<class name="SpeechRecognizer"
|
||||||
|
extends="java.lang.Object"
|
||||||
|
abstract="false"
|
||||||
|
static="false"
|
||||||
|
final="false"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
<method name="cancel"
|
||||||
|
return="void"
|
||||||
|
abstract="false"
|
||||||
|
native="false"
|
||||||
|
synchronized="false"
|
||||||
|
static="false"
|
||||||
|
final="false"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
</method>
|
||||||
|
<method name="createSpeechRecognizer"
|
||||||
|
return="android.speech.SpeechRecognizer"
|
||||||
|
abstract="false"
|
||||||
|
native="false"
|
||||||
|
synchronized="false"
|
||||||
|
static="true"
|
||||||
|
final="false"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
<parameter name="context" type="android.content.Context">
|
||||||
|
</parameter>
|
||||||
|
</method>
|
||||||
|
<method name="createSpeechRecognizer"
|
||||||
|
return="android.speech.SpeechRecognizer"
|
||||||
|
abstract="false"
|
||||||
|
native="false"
|
||||||
|
synchronized="false"
|
||||||
|
static="true"
|
||||||
|
final="false"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
<parameter name="context" type="android.content.Context">
|
||||||
|
</parameter>
|
||||||
|
<parameter name="serviceComponent" type="android.content.ComponentName">
|
||||||
|
</parameter>
|
||||||
|
</method>
|
||||||
|
<method name="destroy"
|
||||||
|
return="void"
|
||||||
|
abstract="false"
|
||||||
|
native="false"
|
||||||
|
synchronized="false"
|
||||||
|
static="false"
|
||||||
|
final="false"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
</method>
|
||||||
|
<method name="isRecognitionAvailable"
|
||||||
|
return="boolean"
|
||||||
|
abstract="false"
|
||||||
|
native="false"
|
||||||
|
synchronized="false"
|
||||||
|
static="true"
|
||||||
|
final="false"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
<parameter name="context" type="android.content.Context">
|
||||||
|
</parameter>
|
||||||
|
</method>
|
||||||
|
<method name="setRecognitionListener"
|
||||||
|
return="void"
|
||||||
|
abstract="false"
|
||||||
|
native="false"
|
||||||
|
synchronized="false"
|
||||||
|
static="false"
|
||||||
|
final="false"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
<parameter name="listener" type="android.speech.RecognitionListener">
|
||||||
|
</parameter>
|
||||||
|
</method>
|
||||||
|
<method name="startListening"
|
||||||
|
return="void"
|
||||||
|
abstract="false"
|
||||||
|
native="false"
|
||||||
|
synchronized="false"
|
||||||
|
static="false"
|
||||||
|
final="false"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
<parameter name="recognizerIntent" type="android.content.Intent">
|
||||||
|
</parameter>
|
||||||
|
</method>
|
||||||
|
<method name="stopListening"
|
||||||
|
return="void"
|
||||||
|
abstract="false"
|
||||||
|
native="false"
|
||||||
|
synchronized="false"
|
||||||
|
static="false"
|
||||||
|
final="false"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
</method>
|
||||||
|
<field name="ERROR_AUDIO"
|
||||||
|
type="int"
|
||||||
|
transient="false"
|
||||||
|
volatile="false"
|
||||||
|
value="3"
|
||||||
|
static="true"
|
||||||
|
final="true"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
</field>
|
||||||
|
<field name="ERROR_CLIENT"
|
||||||
|
type="int"
|
||||||
|
transient="false"
|
||||||
|
volatile="false"
|
||||||
|
value="5"
|
||||||
|
static="true"
|
||||||
|
final="true"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
</field>
|
||||||
|
<field name="ERROR_INSUFFICIENT_PERMISSIONS"
|
||||||
|
type="int"
|
||||||
|
transient="false"
|
||||||
|
volatile="false"
|
||||||
|
value="9"
|
||||||
|
static="true"
|
||||||
|
final="true"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
</field>
|
||||||
|
<field name="ERROR_NETWORK"
|
||||||
|
type="int"
|
||||||
|
transient="false"
|
||||||
|
volatile="false"
|
||||||
|
value="2"
|
||||||
|
static="true"
|
||||||
|
final="true"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
</field>
|
||||||
|
<field name="ERROR_NETWORK_TIMEOUT"
|
||||||
|
type="int"
|
||||||
|
transient="false"
|
||||||
|
volatile="false"
|
||||||
|
value="1"
|
||||||
|
static="true"
|
||||||
|
final="true"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
</field>
|
||||||
|
<field name="ERROR_NO_MATCH"
|
||||||
|
type="int"
|
||||||
|
transient="false"
|
||||||
|
volatile="false"
|
||||||
|
value="7"
|
||||||
|
static="true"
|
||||||
|
final="true"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
</field>
|
||||||
|
<field name="ERROR_RECOGNIZER_BUSY"
|
||||||
|
type="int"
|
||||||
|
transient="false"
|
||||||
|
volatile="false"
|
||||||
|
value="8"
|
||||||
|
static="true"
|
||||||
|
final="true"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
</field>
|
||||||
|
<field name="ERROR_SERVER"
|
||||||
|
type="int"
|
||||||
|
transient="false"
|
||||||
|
volatile="false"
|
||||||
|
value="4"
|
||||||
|
static="true"
|
||||||
|
final="true"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
</field>
|
||||||
|
<field name="ERROR_SPEECH_TIMEOUT"
|
||||||
|
type="int"
|
||||||
|
transient="false"
|
||||||
|
volatile="false"
|
||||||
|
value="6"
|
||||||
|
static="true"
|
||||||
|
final="true"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
</field>
|
||||||
|
<field name="RESULTS_RECOGNITION"
|
||||||
|
type="java.lang.String"
|
||||||
|
transient="false"
|
||||||
|
volatile="false"
|
||||||
|
value=""results_recognition""
|
||||||
|
static="true"
|
||||||
|
final="true"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
</field>
|
||||||
|
</class>
|
||||||
</package>
|
</package>
|
||||||
<package name="android.speech.tts"
|
<package name="android.speech.tts"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ oneway interface IRecognitionListener {
|
|||||||
/**
|
/**
|
||||||
* A network or recognition error occurred.
|
* A network or recognition error occurred.
|
||||||
*
|
*
|
||||||
* @param error code is defined in {@link RecognitionManager}
|
* @param error code is defined in {@link SpeechRecognizer}
|
||||||
*/
|
*/
|
||||||
void onError(in int error);
|
void onError(in int error);
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import android.speech.IRecognitionListener;
|
|||||||
* you want to begin capturing audio; RecognitionService will automatically
|
* you want to begin capturing audio; RecognitionService will automatically
|
||||||
* determine when the user has finished speaking, stream the audio to the
|
* determine when the user has finished speaking, stream the audio to the
|
||||||
* recognition servers, and notify you when results are ready. In most of the cases,
|
* recognition servers, and notify you when results are ready. In most of the cases,
|
||||||
* this class should not be used directly, instead use {@link RecognitionManager} for
|
* this class should not be used directly, instead use {@link SpeechRecognizer} for
|
||||||
* accessing recognition service.
|
* accessing recognition service.
|
||||||
* {@hide}
|
* {@hide}
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import android.content.Intent;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used for receiving notifications from the RecognitionManager when the
|
* Used for receiving notifications from the SpeechRecognizer when the
|
||||||
* recognition related events occur. All the callbacks are executed on the
|
* recognition related events occur. All the callbacks are executed on the
|
||||||
* Application main thread.
|
* Application main thread.
|
||||||
*/
|
*/
|
||||||
@@ -61,7 +61,7 @@ public interface RecognitionListener {
|
|||||||
/**
|
/**
|
||||||
* A network or recognition error occurred.
|
* A network or recognition error occurred.
|
||||||
*
|
*
|
||||||
* @param error code is defined in {@link RecognitionManager}
|
* @param error code is defined in {@link SpeechRecognizer}
|
||||||
*/
|
*/
|
||||||
void onError(int error);
|
void onError(int error);
|
||||||
|
|
||||||
@@ -70,7 +70,7 @@ public interface RecognitionListener {
|
|||||||
*
|
*
|
||||||
* @param results the recognition results. To retrieve the results in {@code
|
* @param results the recognition results. To retrieve the results in {@code
|
||||||
* ArrayList<String>} format use {@link Bundle#getStringArrayList(String)} with
|
* ArrayList<String>} format use {@link Bundle#getStringArrayList(String)} with
|
||||||
* {@link RecognitionManager#RESULTS_RECOGNITION} as a parameter
|
* {@link SpeechRecognizer#RESULTS_RECOGNITION} as a parameter
|
||||||
*/
|
*/
|
||||||
void onResults(Bundle results);
|
void onResults(Bundle results);
|
||||||
|
|
||||||
@@ -78,13 +78,13 @@ public interface RecognitionListener {
|
|||||||
* Called when partial recognition results are available. The callback might be called at any
|
* Called when partial recognition results are available. The callback might be called at any
|
||||||
* time between {@link #onBeginningOfSpeech()} and {@link #onResults(Bundle)} when partial
|
* time between {@link #onBeginningOfSpeech()} and {@link #onResults(Bundle)} when partial
|
||||||
* results are ready. This method may be called zero, one or multiple times for each call to
|
* results are ready. This method may be called zero, one or multiple times for each call to
|
||||||
* {@link RecognitionManager#startListening(Intent)}, depending on the speech recognition
|
* {@link SpeechRecognizer#startListening(Intent)}, depending on the speech recognition
|
||||||
* service implementation. To request partial results, use
|
* service implementation. To request partial results, use
|
||||||
* {@link RecognizerIntent#EXTRA_PARTIAL_RESULTS}
|
* {@link RecognizerIntent#EXTRA_PARTIAL_RESULTS}
|
||||||
*
|
*
|
||||||
* @param partialResults the returned results. To retrieve the results in
|
* @param partialResults the returned results. To retrieve the results in
|
||||||
* ArrayList<String> format use {@link Bundle#getStringArrayList(String)} with
|
* ArrayList<String> format use {@link Bundle#getStringArrayList(String)} with
|
||||||
* {@link RecognitionManager#RESULTS_RECOGNITION} as a parameter
|
* {@link SpeechRecognizer#RESULTS_RECOGNITION} as a parameter
|
||||||
*/
|
*/
|
||||||
void onPartialResults(Bundle partialResults);
|
void onPartialResults(Bundle partialResults);
|
||||||
|
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ public abstract class RecognitionService extends Service {
|
|||||||
RecognitionService.this.onStartListening(intent, mCurrentCallback);
|
RecognitionService.this.onStartListening(intent, mCurrentCallback);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
listener.onError(RecognitionManager.ERROR_RECOGNIZER_BUSY);
|
listener.onError(SpeechRecognizer.ERROR_RECOGNIZER_BUSY);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.d(TAG, "onError call from startListening failed");
|
Log.d(TAG, "onError call from startListening failed");
|
||||||
}
|
}
|
||||||
@@ -100,10 +100,10 @@ public abstract class RecognitionService extends Service {
|
|||||||
private void dispatchStopListening(IRecognitionListener listener) {
|
private void dispatchStopListening(IRecognitionListener listener) {
|
||||||
try {
|
try {
|
||||||
if (mCurrentCallback == null) {
|
if (mCurrentCallback == null) {
|
||||||
listener.onError(RecognitionManager.ERROR_CLIENT);
|
listener.onError(SpeechRecognizer.ERROR_CLIENT);
|
||||||
Log.w(TAG, "stopListening called with no preceding startListening - ignoring");
|
Log.w(TAG, "stopListening called with no preceding startListening - ignoring");
|
||||||
} else if (mCurrentCallback.mListener.asBinder() != listener.asBinder()) {
|
} else if (mCurrentCallback.mListener.asBinder() != listener.asBinder()) {
|
||||||
listener.onError(RecognitionManager.ERROR_RECOGNIZER_BUSY);
|
listener.onError(SpeechRecognizer.ERROR_RECOGNIZER_BUSY);
|
||||||
Log.w(TAG, "stopListening called by other caller than startListening - ignoring");
|
Log.w(TAG, "stopListening called by other caller than startListening - ignoring");
|
||||||
} else { // the correct state
|
} else { // the correct state
|
||||||
RecognitionService.this.onStopListening(mCurrentCallback);
|
RecognitionService.this.onStopListening(mCurrentCallback);
|
||||||
@@ -175,7 +175,7 @@ public abstract class RecognitionService extends Service {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Log.e(TAG, "call for recognition service without RECORD_AUDIO permissions");
|
Log.e(TAG, "call for recognition service without RECORD_AUDIO permissions");
|
||||||
listener.onError(RecognitionManager.ERROR_INSUFFICIENT_PERMISSIONS);
|
listener.onError(SpeechRecognizer.ERROR_INSUFFICIENT_PERMISSIONS);
|
||||||
} catch (RemoteException re) {
|
} catch (RemoteException re) {
|
||||||
Log.e(TAG, "sending ERROR_INSUFFICIENT_PERMISSIONS message failed", re);
|
Log.e(TAG, "sending ERROR_INSUFFICIENT_PERMISSIONS message failed", re);
|
||||||
}
|
}
|
||||||
@@ -252,7 +252,7 @@ public abstract class RecognitionService extends Service {
|
|||||||
/**
|
/**
|
||||||
* The service should call this method when a network or recognition error occurred.
|
* The service should call this method when a network or recognition error occurred.
|
||||||
*
|
*
|
||||||
* @param error code is defined in {@link RecognitionManager}
|
* @param error code is defined in {@link SpeechRecognizer}
|
||||||
*/
|
*/
|
||||||
public void error(int error) throws RemoteException {
|
public void error(int error) throws RemoteException {
|
||||||
mCurrentCallback = null;
|
mCurrentCallback = null;
|
||||||
@@ -263,12 +263,12 @@ public abstract class RecognitionService extends Service {
|
|||||||
* The service should call this method when partial recognition results are available. This
|
* The service should call this method when partial recognition results are available. This
|
||||||
* method can be called at any time between {@link #beginningOfSpeech()} and
|
* method can be called at any time between {@link #beginningOfSpeech()} and
|
||||||
* {@link #results(Bundle)} when partial results are ready. This method may be called zero,
|
* {@link #results(Bundle)} when partial results are ready. This method may be called zero,
|
||||||
* one or multiple times for each call to {@link RecognitionManager#startListening(Intent)},
|
* one or multiple times for each call to {@link SpeechRecognizer#startListening(Intent)},
|
||||||
* depending on the speech recognition service implementation.
|
* depending on the speech recognition service implementation.
|
||||||
*
|
*
|
||||||
* @param partialResults the returned results. To retrieve the results in
|
* @param partialResults the returned results. To retrieve the results in
|
||||||
* ArrayList<String> format use {@link Bundle#getStringArrayList(String)} with
|
* ArrayList<String> format use {@link Bundle#getStringArrayList(String)} with
|
||||||
* {@link RecognitionManager#RESULTS_RECOGNITION} as a parameter
|
* {@link SpeechRecognizer#RESULTS_RECOGNITION} as a parameter
|
||||||
*/
|
*/
|
||||||
public void partialResults(Bundle partialResults) throws RemoteException {
|
public void partialResults(Bundle partialResults) throws RemoteException {
|
||||||
mListener.onPartialResults(partialResults);
|
mListener.onPartialResults(partialResults);
|
||||||
@@ -289,7 +289,7 @@ public abstract class RecognitionService extends Service {
|
|||||||
*
|
*
|
||||||
* @param results the recognition results. To retrieve the results in {@code
|
* @param results the recognition results. To retrieve the results in {@code
|
||||||
* ArrayList<String>} format use {@link Bundle#getStringArrayList(String)} with
|
* ArrayList<String>} format use {@link Bundle#getStringArrayList(String)} with
|
||||||
* {@link RecognitionManager#RESULTS_RECOGNITION} as a parameter
|
* {@link SpeechRecognizer#RESULTS_RECOGNITION} as a parameter
|
||||||
*/
|
*/
|
||||||
public void results(Bundle results) throws RemoteException {
|
public void results(Bundle results) throws RemoteException {
|
||||||
mCurrentCallback = null;
|
mCurrentCallback = null;
|
||||||
|
|||||||
@@ -38,16 +38,16 @@ import java.util.Queue;
|
|||||||
/**
|
/**
|
||||||
* This class provides access to the speech recognition service. This service allows access to the
|
* This class provides access to the speech recognition service. This service allows access to the
|
||||||
* speech recognizer. Do not instantiate this class directly, instead, call
|
* speech recognizer. Do not instantiate this class directly, instead, call
|
||||||
* {@link RecognitionManager#createRecognitionManager(Context)}. This class's methods must be
|
* {@link SpeechRecognizer#createSpeechRecognizer(Context)}. This class's methods must be
|
||||||
* invoked only from the main application thread. Please note that the application must have
|
* invoked only from the main application thread. Please note that the application must have
|
||||||
* {@link android.Manifest.permission#RECORD_AUDIO} permission to use this class.
|
* {@link android.Manifest.permission#RECORD_AUDIO} permission to use this class.
|
||||||
*/
|
*/
|
||||||
public class RecognitionManager {
|
public class SpeechRecognizer {
|
||||||
/** DEBUG value to enable verbose debug prints */
|
/** DEBUG value to enable verbose debug prints */
|
||||||
private final static boolean DBG = false;
|
private final static boolean DBG = false;
|
||||||
|
|
||||||
/** Log messages identifier */
|
/** Log messages identifier */
|
||||||
private static final String TAG = "RecognitionManager";
|
private static final String TAG = "SpeechRecognizer";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to retrieve an {@code ArrayList<String>} from the {@link Bundle} passed to the
|
* Used to retrieve an {@code ArrayList<String>} from the {@link Bundle} passed to the
|
||||||
@@ -133,10 +133,10 @@ public class RecognitionManager {
|
|||||||
private final InternalListener mListener = new InternalListener();
|
private final InternalListener mListener = new InternalListener();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The right way to create a {@code RecognitionManager} is by using
|
* The right way to create a {@code SpeechRecognizer} is by using
|
||||||
* {@link #createRecognitionManager} static factory method
|
* {@link #createSpeechRecognizer} static factory method
|
||||||
*/
|
*/
|
||||||
private RecognitionManager(final Context context, final ComponentName serviceComponent) {
|
private SpeechRecognizer(final Context context, final ComponentName serviceComponent) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mServiceComponent = serviceComponent;
|
mServiceComponent = serviceComponent;
|
||||||
}
|
}
|
||||||
@@ -167,10 +167,10 @@ public class RecognitionManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether a speech recognition service is available on the system. If this method
|
* Checks whether a speech recognition service is available on the system. If this method
|
||||||
* returns {@code false}, {@link RecognitionManager#createRecognitionManager(Context)} will
|
* returns {@code false}, {@link SpeechRecognizer#createSpeechRecognizer(Context)} will
|
||||||
* fail.
|
* fail.
|
||||||
*
|
*
|
||||||
* @param context with which {@code RecognitionManager} will be created
|
* @param context with which {@code SpeechRecognizer} will be created
|
||||||
* @return {@code true} if recognition is available, {@code false} otherwise
|
* @return {@code true} if recognition is available, {@code false} otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isRecognitionAvailable(final Context context) {
|
public static boolean isRecognitionAvailable(final Context context) {
|
||||||
@@ -180,41 +180,41 @@ public class RecognitionManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory method to create a new {@code RecognitionManager}. Please note that
|
* Factory method to create a new {@code SpeechRecognizer}. Please note that
|
||||||
* {@link #setRecognitionListener(RecognitionListener)} should be called before dispatching any
|
* {@link #setRecognitionListener(RecognitionListener)} should be called before dispatching any
|
||||||
* command to the created {@code RecognitionManager}, otherwise no notifications will be
|
* command to the created {@code SpeechRecognizer}, otherwise no notifications will be
|
||||||
* received.
|
* received.
|
||||||
*
|
*
|
||||||
* @param context in which to create {@code RecognitionManager}
|
* @param context in which to create {@code SpeechRecognizer}
|
||||||
* @return a new {@code RecognitionManager}
|
* @return a new {@code SpeechRecognizer}
|
||||||
*/
|
*/
|
||||||
public static RecognitionManager createRecognitionManager(final Context context) {
|
public static SpeechRecognizer createSpeechRecognizer(final Context context) {
|
||||||
return createRecognitionManager(context, null);
|
return createSpeechRecognizer(context, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory method to create a new {@code RecognitionManager}. Please note that
|
* Factory method to create a new {@code SpeechRecognizer}. Please note that
|
||||||
* {@link #setRecognitionListener(RecognitionListener)} should be called before dispatching any
|
* {@link #setRecognitionListener(RecognitionListener)} should be called before dispatching any
|
||||||
* command to the created {@code RecognitionManager}, otherwise no notifications will be
|
* command to the created {@code SpeechRecognizer}, otherwise no notifications will be
|
||||||
* received.
|
* received.
|
||||||
*
|
*
|
||||||
* Use this version of the method to specify a specific service to direct this
|
* Use this version of the method to specify a specific service to direct this
|
||||||
* {@link RecognitionManager} to. Normally you would not use this; use
|
* {@link SpeechRecognizer} to. Normally you would not use this; use
|
||||||
* {@link #createRecognitionManager(Context)} instead to use the system default recognition
|
* {@link #createSpeechRecognizer(Context)} instead to use the system default recognition
|
||||||
* service.
|
* service.
|
||||||
*
|
*
|
||||||
* @param context in which to create {@code RecognitionManager}
|
* @param context in which to create {@code SpeechRecognizer}
|
||||||
* @param serviceComponent the {@link ComponentName} of a specific service to direct this
|
* @param serviceComponent the {@link ComponentName} of a specific service to direct this
|
||||||
* {@code RecognitionManager} to
|
* {@code SpeechRecognizer} to
|
||||||
* @return a new {@code RecognitionManager}
|
* @return a new {@code SpeechRecognizer}
|
||||||
*/
|
*/
|
||||||
public static RecognitionManager createRecognitionManager(final Context context,
|
public static SpeechRecognizer createSpeechRecognizer(final Context context,
|
||||||
final ComponentName serviceComponent) {
|
final ComponentName serviceComponent) {
|
||||||
if (context == null) {
|
if (context == null) {
|
||||||
throw new IllegalArgumentException("Context cannot be null)");
|
throw new IllegalArgumentException("Context cannot be null)");
|
||||||
}
|
}
|
||||||
checkIsCalledFromMainThread();
|
checkIsCalledFromMainThread();
|
||||||
return new RecognitionManager(context, serviceComponent);
|
return new SpeechRecognizer(context, serviceComponent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -223,7 +223,7 @@ public class RecognitionManager {
|
|||||||
* listener.
|
* listener.
|
||||||
*
|
*
|
||||||
* @param listener listener that will receive all the callbacks from the created
|
* @param listener listener that will receive all the callbacks from the created
|
||||||
* {@link RecognitionManager}, this must not be null.
|
* {@link SpeechRecognizer}, this must not be null.
|
||||||
*/
|
*/
|
||||||
public void setRecognitionListener(RecognitionListener listener) {
|
public void setRecognitionListener(RecognitionListener listener) {
|
||||||
checkIsCalledFromMainThread();
|
checkIsCalledFromMainThread();
|
||||||
@@ -303,7 +303,7 @@ public class RecognitionManager {
|
|||||||
private static void checkIsCalledFromMainThread() {
|
private static void checkIsCalledFromMainThread() {
|
||||||
if (Looper.myLooper() != Looper.getMainLooper()) {
|
if (Looper.myLooper() != Looper.getMainLooper()) {
|
||||||
throw new RuntimeException(
|
throw new RuntimeException(
|
||||||
"RecognitionManager should be used only from the application's main thread");
|
"SpeechRecognizer should be used only from the application's main thread");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -373,7 +373,7 @@ public class RecognitionManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destroys the {@code RecognitionManager} object.
|
* Destroys the {@code SpeechRecognizer} object.
|
||||||
*/
|
*/
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
if (mConnection != null) {
|
if (mConnection != null) {
|
||||||
Reference in New Issue
Block a user