Android 如果选择了增强的Google服务,SpeechRecognitor将不工作
如果我在语音输入设置中选择“增强的谷歌服务”,我的应用程序中的语音输入将不起作用(请参见屏幕截图): 我使用不带对话框的语音识别:Android 如果选择了增强的Google服务,SpeechRecognitor将不工作,android,voice-recognition,voice,google-voice,google-voice-search,Android,Voice Recognition,Voice,Google Voice,Google Voice Search,如果我在语音输入设置中选择“增强的谷歌服务”,我的应用程序中的语音输入将不起作用(请参见屏幕截图): 我使用不带对话框的语音识别: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); MyRecognitionListener listener
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
MyRecognitionListener listener = new MyRecognitionListener();
sr = SpeechRecognizer.createSpeechRecognizer(this);
sr.setRecognitionListener(listener);
findViewById(R.id.bt1).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 1);
intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE,"voice.recognition.query");
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "en_US");
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, "en_US");
intent.putExtra(RecognizerIntent.EXTRA_ONLY_RETURN_LANGUAGE_PREFERENCE, "en_US");
sr.startListening(intent);
}
});
}
请您帮忙,有什么问题吗?您使用的是哪个版本的Android和Google?Nexus 10和Android v5.1.1请在尝试运行代码时发布未过滤的日志。当Google应用程序检测到另一个应用程序需要麦克风时(它可以这样做,因为它是一个系统应用程序),它应该释放麦克风资源,并且logcat应该显示此输出。E/SpeechRecognizer﹕ 绑定到识别服务失败您解决此问题了吗?