I am developing an Android application which always listen voice from user. It works when I run it on Sony X10i, but doesn't work in Samsung Galaxy SII. Here is my code:
SpeechRecognizer speechRecognizer;
speechRecognizer = SpeechRecognizer.createSpeechRecognizer(getBaseContext());
MyRecognitionListener speechListner=new MyRecognitionListener();
speechRecognizer.setRecognitionListener(speechListner);
speechRecognizer.startListening(RecognizerIntent.getVoiceDetailsIntent(getApplicationContext()));
Here is my listener class:
class MyRecognitionListener implements RecognitionListener {
public void onBeginningOfSpeech() {
Log.d("leapkh", "onBeginningOfSpeech");
}
public void onBufferReceived(byte[] buffer) {
Log.d("leapkh", "onBufferReceived");
}
public void onEndOfSpeech() {
Log.d("leapkh", "onEndOfSpeech");
}
public void onError(int error) {
Log.d("leapkh", "onError");
}
public void onEvent(int eventType, Bundle params) {
Log.d("leapkh", "onEvent");
}
public void onPartialResults(Bundle partialResults) {
Log.d("leapkh", "onPartialResults");
}
public void onReadyForSpeech(Bundle params) {
Log.d("leapkh", "onReadyForSpeech");
}
public void onResults(Bundle results) {
Log.d("leapkh", "onResults");
}
public void onRmsChanged(float rmsdB) {
Log.d("leapkh", "onRmsChanged");
}
}
In this case, how to solve this problem?
I found the solution.
Change the parameter of
speechRecognizer.startListening()
method tointent
as below:Change the parameters you are passing with the intent
}
Also Check which type of error you are getting for nomatch,network and server error call startListening again