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

后端 未结 4 1506
独厮守ぢ
独厮守ぢ 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

    Another way would be to :

    In your AndroidManifest.xml, find your entry for your activity and add the following attribute and value:

    android:configChanges="orientation|screenSize"
    

    This will stop your activity from being destroyed and recreated on orientation.

提交回复
热议问题