How can I stop SpeechRecognizer
from requesting audio focus? I want to disable SpeechRecognizer's beep (mute all audio is not a solution) while MediaPlayer
could still play some audio files (in another context - service)
So in my app I request audio focus only for service with MediaPlayer (audio-service)
...
AudioManager am = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
int result = am.requestAudioFocus(null,
AudioManager.STREAM_MUSIC,
AudioManager.AUDIOFOCUS_GAIN);
if (result == AudioManager.AUDIOFOCUS_REQUEST_GRANTED) {
...
mMediaPlayer.start();
}
SpeechRecognizer instance in another service (speech-service):
speech = SpeechRecognizer.createSpeechRecognizer(this);
When SpeechRecognizer starts listening in speech-service (speech.startListening(recognizerIntent);
) it automatically requests audio focus and it still can play this annoying beep sound. At the same time in audio-service I get AUDIOFOCUS_LOSS_TRANSIENT
in OnAudioFocusChangeListener
and I have code lines to pause MediaPlayer when audiofocus loss happens
So is it even possible to disable SpeechRecognizer's beep without muting sound (STREAM_MUSIC/STREAM_SYSTEM) or not using root?