简体   繁体   English

语音识别在 Android 11+ 中不起作用

[英]Speech Recognition is not working in Android 11+

I using speech recognition google API its working fine in Android 10 and below but unfortunately stop working after updating API to android 30, and Method Provide null result我使用语音识别谷歌 API 它在 Android 10 及以下工作正常但不幸的是在将 API 更新为 android 30 和方法提供 null 结果后停止工作

  @Override
   public void onPartialResults(Bundle partialResults) {
          ArrayList<String> stringArrayList = partialResults.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
          String result;
           if (stringArrayList != null) {
                result = stringArrayList.get(0);
                String stringBuilder = oldText + result;
                editText.setText(stringBuilder);
                editText.setSelection(editText.getText().length());
           }
  }

and logcat response和 logcat 响应

E/SpeechRecognizer: bind to recognition service failed

The problem seems to be related to this new Android 11 "feature" , and the solution could be to add a query to the manifest for the blocked intent:这个问题似乎与这个新的 Android 11 "feature"有关,解决方案可能是向清单中添加一个查询以获取被阻止的意图:

<manifest ...>
    <queries>
        <intent>
            <action android:name="android.speech.RecognitionService" />
        </intent>
    </queries>

Please let me know the results.请让我知道结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM