I use Android speech recognition service from my application.
It turns out that when two clients attempt to send requests at the same time (say, the user started one voice search from an app, then switched to another application while the search is still active, and launched another search), the service stops working.
Is there a way to determine that there's a voice recognition session in progress, so that I can refuse to start another one?
You should probably be trapping ERROR_RECOGNIZER_BUSY in the onError handler:
@Override
public void onError(int error) {
switch (error) {
case SpeechRecognizer.ERROR_RECOGNIZER_BUSY:
// do something reasonable
…
}
}
You're most likely (only?) going to receive that on a request to start listening; unfortunately, I'm not aware of any way to test this condition without trying (e.g. I don't think you can pre-detect another process's listener being active to remove a microphone button)
(On stopping listening, you'd only get this error if you were trying to kill another process's listener somehow.)
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