I have been trying to use Android\'s AudioManager.setMicrophoneMute()
without much success. That is, it simply refuses to mute the microphone, no matter what I
I found the same issues on samsung Galaxy and I solved it by using MODE_IN_COMMUNICATION
mode.
In the AudioManager.java source codeit says :
MODE_IN_CALL
- In call audio mode. A telephony call is established.MODE_IN_COMMUNICATION
- In communication audio mode. An audio/video chat or VoIP call is established.Because i use the third VOIP library, I use the MODE_IN_COMMUNICATION
and it solved the issue.
AudioManager audioManager = (AudioManager)
context.getSystemService(Context.AUDIO_SERVICE);
// get original mode
int originalMode = audioManager.getMode();
audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
// change mute
boolean state = !audioManager.isMicrophoneMute();
audioManager.setMicrophoneMute(state);
// set mode back
audioManager.setMode(originalMode);