Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/197.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android语音输入在魅族M5上挂起我的应用程序_Android_Voice Recognition_Voice_Google Voice_Google Voice Search - Fatal编程技术网

Android语音输入在魅族M5上挂起我的应用程序

Android语音输入在魅族M5上挂起我的应用程序,android,voice-recognition,voice,google-voice,google-voice-search,Android,Voice Recognition,Voice,Google Voice,Google Voice Search,我在Android应用程序中使用无对话框语音输入: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); MyRecognitionListener listener = new MyRecognitionListener(); sr = S

我在Android应用程序中使用无对话框语音输入:

@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 onButtonClick(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);
        }
   });     
}
一些用户报告说,在魅族M5上点击按钮(在onButtonClick监听器中)后,应用程序挂起。其他设备没有任何问题。一位魅族M5用户发送了以下错误报告:

Stack:
java.lang.IllegalStateException: Could not execute method for android:onClick
at android.view.View$DeclaredOnClickListener.onClick(View.java:4543)
at android.view.View.performClick(View.java:5317)
at android.view.View$PerformClick.run(View.java:21648)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5896)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:948)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:809)
at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:102)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at android.view.View$DeclaredOnClickListener.onClick(View.java:4538)
... 10 more
Caused by: java.lang.SecurityException: Not allowed to bind to service Intent { act=android.speech.RecognitionService cmp=com.mediatek.voicecommand/.service.VoiceWakeupRecognitionService }
at android.app.ContextImpl.bindServiceCommon(ContextImpl.java:1421)
at android.app.ContextImpl.bindService(ContextImpl.java:1385)
at android.content.ContextWrapper.bindService(ContextWrapper.java:604)
at android.speech.SpeechRecognizer.startListening(SpeechRecognizer.java:287)
at com.TestAPP.MainActivity.onBtClick(Unknown Source)
... 12 more

你能帮我用魅族M5解决这个问题吗?

没有日志就帮不上忙。我已经更新了帖子并添加了日志。SecurityException可能表明这是权限问题。检查此方向看起来您可能需要在清单中定义
com.mediatek.voicecommand.service.VoiceWakeupRecognitionService
,添加了以下权限,但没有帮助:我做错了什么?