Can anybody tell me how to mute earpiece in android (targetSdkVersion 26). I tried this:
audioManager.setSpeakerphoneOn(false);
but it only mutes the speaker, not the earpiece.
I also tried this:
audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
audioManager.setStreamVolume(STREAM_VOICE_CALL, 0, AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE);
and this:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
am.requestAudioFocus(new AudioFocusRequest.Builder(AudioManager.AUDIOFOCUS_GAIN_TRANSIENT_EXCLUSIVE)
.setAudioAttributes(new AudioAttributes.Builder().setUsage(USAGE_VOICE_COMMUNICATION).build()).build());
am.adjustVolume(AudioManager.ADJUST_MUTE, AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE);
}
with the same effect.
I work with webrtc and my goal is to mute/unmute the output audio. Thank you very much.