我正在开发一个Android应用程序,它总是从用户听的声音。 它的工作原理,当我在索尼X10i的运行它,但在三星Galaxy SII不起作用。 这里是我的代码:
SpeechRecognizer speechRecognizer;
speechRecognizer = SpeechRecognizer.createSpeechRecognizer(getBaseContext());
MyRecognitionListener speechListner=new MyRecognitionListener();
speechRecognizer.setRecognitionListener(speechListner);
speechRecognizer.startListening(RecognizerIntent.getVoiceDetailsIntent(getApplicationContext()));
这里是我的监听器类:
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");
}
}
在这种情况下,如何解决这个问题呢?