I am trying to write an app to route audio output on speaker BUT leave microphone on wired headset when the headset is connected.
It is possible to route audio output on speaker when headset is connected with the following code:
AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
audioManager.setWiredHeadsetOn(false);
audioManager.setSpeakerphoneOn(true);
audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
However, when I do this, headset microphone is also disabled. But I need it to receive audio input.
How can I separately manage input and output devices ?
To the following question, there is a solution (at the bottom) but it is only valid if I start the mediaplayer. In my case, I am trying to route the media of other apps to the speaker.
Route MIC input through headset and AUDIO output through phone's speaker
Is there any way to do it ?