While testing an application after increasing the targetLevel to 30, I found that the SpeechRecognizer is not available any more, i.e. SpeechRecognizer.isRecognitionAvailable()
always return false.
If I set the targetLevel back to 29, without changing anything else, it is available again. This happens on a real device (Pixel 3a) and the emulator.
It doesn't seem to be a behaviour change. The only requirement mentioned by the Recognizer API is the Manifest.permission.RECORD_AUDIO
I also found no clue in the logcat.
Bookmark this question. Show activity on this post. While testing an application after increasing the targetLevel to 30, I found that the SpeechRecognizer is not available any more, i.e. SpeechRecognizer.isRecognitionAvailable () always return false. If I set the targetLevel back to 29, without changing anything else, it is available again.
Like earlier releases, Android 11 includes behavior changes that may affect your app. The following behavior changes apply exclusively to apps that are targeting Android 11 or higher. If your app sets targetSdkVersion to 30, you should modify your app to support these behaviors properly, where applicable.
The Speech Recognition function does not work with "UseLegacy" unchecked. I created an app with UseLegacy unchecked today and it does not work. I can't get result from the function. If I check the UseLegacy checkbox, it works. *The Google dialog pop up. this with UseLegacy unchecked.
If your app does not target Android 11, some of these changes might not immediately affect you. However, while you can currently use some non-SDK interfaces ( depending on your app's target API level ), using any non-SDK method or field always carries a high risk of breaking your app.
I finally found a solution.
Trying to actually use the (allegedly not available) recognizer lead to this message in the logcat :
10-13 09:19:50.273 1531 1799 I AppsFilter: interaction: PackageSetting{eb6a1b2 my.application.package/10225} -> PackageSetting{ab34503 com.google.android.googlequicksearchbox/10140} BLOCKED
10-13 09:19:50.273 1531 1799 W ActivityManager: Unable to start service Intent { act=android.speech.RecognitionService cmp=com.google.android.googlequicksearchbox/com.google.android.voicesearch.serviceapi.GoogleRecognitionService } U=0: not found
10-13 09:19:50.273 25348 25348 E SpeechRecognizer: bind to recognition service failed
So the problem seems to be related to this new Android 11 "feature", and the solution was to add a query to the manifest for the blocked intent :
<manifest ...>
<queries>
<intent>
<action android:name="android.speech.RecognitionService" />
</intent>
</queries>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With