@Override public void onResults(Bundle results) { if (recognitionCallback != null) recognitionCallback.onRecognitionDone( results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION).get(0)); recognitionCallback = null; exceptionCallback = null; }
@Override public void onError(int error) { switch (error) { case SpeechRecognizer.ERROR_AUDIO: if (exceptionCallback != null) exceptionCallback.onException(new Exception("Audio recording error.")); break; case SpeechRecognizer.ERROR_CLIENT: if (exceptionCallback != null) exceptionCallback.onException(new Exception("Other client side errors.")); break; case SpeechRecognizer.ERROR_INSUFFICIENT_PERMISSIONS: if (exceptionCallback != null) exceptionCallback.onException(new Exception("Insufficient permissions.")); break; case SpeechRecognizer.ERROR_NETWORK: if (exceptionCallback != null) exceptionCallback.onException(new Exception("Other network related errors.")); break; case SpeechRecognizer.ERROR_NETWORK_TIMEOUT: if (exceptionCallback != null) exceptionCallback.onException(new Exception("Network operation timed out.")); break; case SpeechRecognizer.ERROR_NO_MATCH: if (recognitionCallback != null) recognitionCallback.onRecognitionDone(""); break; case SpeechRecognizer.ERROR_RECOGNIZER_BUSY: if (exceptionCallback != null) exceptionCallback.onException(new Exception("RecognitionService busy.")); break; case SpeechRecognizer.ERROR_SERVER: if (exceptionCallback != null) exceptionCallback.onException(new Exception("Server sends error status.")); break; case SpeechRecognizer.ERROR_SPEECH_TIMEOUT: if (recognitionCallback != null) recognitionCallback.onRecognitionDone(""); break; } recognitionCallback = null; exceptionCallback = null; }