Losing 'MediaPlayer' (& other Variables) when Device is Rotated

后端 未结 4 1515
独厮守ぢ
独厮守ぢ 2021-01-07 13:06

I\'m creating a music player for Android and it\'s mostly working. The problem is that when I turn the device horizontally I lose all the variables from the Activity (which

4条回答
  •  无人及你
    2021-01-07 13:20

    You should use a Service to Provides "background" audio playback capabilities, allowing the user to switch between activities or Rotate device without stopping playback.

    Check out android_packages_apps_Music which is opensource by CM on github , It use MediaPlaybackService extends Service to do this , checkout MediaPlaybackService.java

提交回复
热议问题