I created App to App Android Sinch Application. When user on call without headphone its working on speaker but if user connect headphone its not automatically connecting to headphone instead of that i need to manually mute speaker and its connecting to headphone. Please check the code i done.
private void enableSpeaker(boolean enable) {
AudioController audioController = getSinchServiceInterface().getAudioController();
if (enable)
audioController.enableSpeaker();
else
audioController.disableSpeaker();
switchVolume.setImageDrawable(ContextCompat.getDrawable(this, isSpeaker ? R.drawable.ic_speaker : R.drawable.ic_speaker_off));
}
private void setMuteUnmute() {
AudioController audioController = getSinchServiceInterface().getAudioController();
if (isMute) {
audioController.mute();
switchMic.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_mic_off));
} else {
audioController.unmute();
switchMic.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_mic_on));
}
}
I think you enabled Speaker in your
onCallEstablished
method.Remove
enableSpeaker()
method fromonCallEstablished
method and addenableAutomaticAudioRouting()
like below.For more details check sinch documentation Here