So I am trying to use some code found here on Stack Overflow in order to route audio from the Headset to the Speakers.
What I am currently doing is:
AudioManager am = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
am.setMode(AudioManager.STREAM_MUSIC);
am.setSpeakerphoneOn(true);
sleep(15000);
What happens is that the audio is routed during the "sleep", however it gets back to the headset after the 15 seconds. If I perform this without the sleep, the sound will go to the speaker and back to the headset very quickly.
After this call, my program dies. I would like that this would persist in the system, as the app Headset Toggle does