AudioManager audioManager = (AudioManager)getSystemService(AUDIO_SERVICE);
audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
We have this code to do a video call on Speaker. If user connects earphones, then we we are checking using the below code.
if(audioManager.isWiredHeadsetOn()) {
audioManager.setWiredHeadsetOn(true);
} else {
audioManager.setSpeakerphoneOn(true);
}
But the above code detects headset but audio is still on speaker rather than in earphones. How to fix this ?
And i want to know how to handle if user connects headset during a call. How to detect and send Audio through earphones at that time ?