Is Android's speech recognition service busy?

I am using the Android speech recognition service from my application.

It turns out that when two clients simultaneously try to send requests (for example, the user started one voice search from the application, then switched to another application while the search is still active and started another search), the service stops working.

Is there a way to determine if a voice recognition session is going on there so that I can refuse to start another?

+7
source share
2 answers

You should probably catch ERROR_RECOGNIZER_BUSY in the onError handler:

@Override public void onError(int error) { switch (error) { case SpeechRecognizer.ERROR_RECOGNIZER_BUSY: // do something reasonable โ€ฆ } } 

You are most likely (only?) To get this on request to start listening; unfortunately, I donโ€™t know how to test this condition without trying (for example, I donโ€™t think that you can previously detect that another listener of the process is active in order to remove the microphone button)

(When you stop listening, you will receive this error only if you try to somehow kill another listener of the process.)

+1
source

I received this error (ERROR_RECOGNIZER_BUSY) and found out that the package was not installed in my intention. So I just added this line, and now it works:

 Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); ... intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, context.getPackageName()); 
0
source

All Articles