title: Android AudioManager.setSpeakerphoneOn stops working after sleep
body: <p>So I am trying to use some code found here on Stack Overflow in order to route audio from the Headset to the Speakers.</p>
  
  <p>What I am currently doing is:</p>
  
  <pre><code>AudioManager am = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
  am.setMode(AudioManager.STREAM_MUSIC);
  am.setSpeakerphoneOn(true);
  sleep(15000);
  </code></pre>
  
  <p>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.</p>
  
  <p>After this call, my program dies. I would like that this would persist in the system, as the app <a href="https://play.google.com/store/apps/details?id=com.bjemtj.headsettoggle&amp;hl=en" rel="nofollow">Headset Toggle</a> does</p>