In my app i'm recording audio via Bluetooth and playback the audio to wire headset at the same time. My app works on older OS but not the latest OS.
I've been searching and reading old postings and could not figure a way to force audio play back to headset or ear piece using AudioTracker on newer Android OS 9+ while connected to Bluetooth audio.
I read this link but it does not work on AndroidOS 9+
Route default audio to ear piece
Set Audio manager
manager = (AudioManager) this.getSystemService(Context.AUDIO_SERVICE);
manager.setMode(MODE_IN_COMMUNICATION);
Playback using AudioTrack
player = new AudioTrack(MODE_IN_COMMUNICATION, sample_rate, AudioFormat.CHANNEL_OUT_MONO,
AudioFormat.ENCODING_PCM_16BIT, minBuffer, AudioTrack.MODE_STREAM);
With the above the playback is output to the Bluetooth device. I have tried the Reflection code above and it does not work.
Is it possible to reroute playback audio when connected to Bluetooth device?