我的工作SpeechRecognizer听者活动。
我触发意图从网页视图按钮点击(startListning(意向))抛出的javascript
act.startFun();
而startFun()方法是在我MainActivity.java文件中声明
public void startFun(){
Log.d(TAG,"ONCLICK");
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE,"voice.recognition.test");
intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS,5);
sr.startListening(intent);
}
我SpeechRecognizer听者像
class listner implements RecognitionListener{
public void onResults(Bundle results) {
end=1;
Log.d(TAG, "onResults");
}
public void onRmsChanged(float rmsdB) {
Log.d(TAG, "onRmsChanged");
}
}
我的要求是我想通过onResults(捆绑的结果)的结果字符串到我的JavaScript方法。
请有人帮助我实现这一目标。