As zapl said, there is no direct method to do this, but you can try to mute the system volume, and, like you, Tencent said that you avoid any hacking. Then I have to say that for this there is no SO FAR method. But still, I share this solution for those who suffer from the same problem, and perhaps not against the βtrickβ. Just saving your hours of frustration.
Unmount the system volume for that particular time, and then mute the sound. How to do it:
In your class, create the following objects
private AudioManager mAudioManager; private int mStreamVolume = 0;
In your onCreate mode, follow these steps:
mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
When you start listening to speech recognition, follow these steps:
speechRecognizer.startListening(intent); // this method make that annoying sound mStreamVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC); // getting system volume into var for later un-muting mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, 0, 0); // setting system volume to zero, muting
The SpeRec RecognitionListener interface must have an onReadyForSpeech method.
class MyRecognitionListener implements RecognitionListener { public void onReadyForSpeech(Bundle params) {
Here's how you can play the trick with this annoying sound. Obviously, any other sound will also be muted within a second.
Bilal rabbani
source share