title: Android: Keep MediaPlayer running during Activity screen orientation update
body: <p>I use a MediaPlayer to play an MP3. Currently I disabled screen orientation changes by using</p>
  
  <pre><code>android:screenOrientation="portrait"
  android:configChanges="keyboardHidden|orientation"
  </code></pre>
  
  <p>in the manifest. I do want to support landscape mode now - i.e. removed those tags - but have the problem that during the destroy/create cycle the player gets stopped and then restarted. This is okay and I actually do this even manually in <code>onPause()</code> to stop the player when the activity goes in the background.</p>
  
  <p>To keep it running during orientation changes now, I tried making it static (and using the Application Context to create it once). Of course, when I remove the <code>player.stop()</code> in <code>onPause()</code> now, it does what I want - well, <em>until</em> the Activity goes in the background.</p>
  
  <p>So, two questions:</p>
  
  <ul>
  <li>How can I determine if the Activity will be recreated directly after the call to <code>onStop()</code></li>
  <li>Or: How can I keep the <code>MediaPlayer</code> running during that cycle, yet stop it when the App goes in the background?</li>
  </ul>