Search code examples
androidspeech-recognitionspeech-recognition-api

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

  @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

E/SpeechRecognizer: bind to recognition service failed

Solution

  • 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 :

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

    Please let me know the results.