Skip to content Skip to sidebar Skip to footer

Music(activity) Restarts When Rotating Device...why Does It Happen?and How Can I Stop It From Restarting?

well i think my question describes itself , anyways here is the code public class NowPlaying extends Activity implements Serializable { static MediaPlayer mp =new MediaPlayer

Solution 1:

it restarts because your activity was recreated... each time the user change the orientation of the device the oncreate method is called again. to fix this try add this to your activity in the manifest file:

   android:configChanges="orientation|keyboardHidden">

Solution 2:

Try this in your manifest...

<activityandroid:name="Your Activity Name"android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"android:windowSoftInputMode="adjustPan"/>

Post a Comment for "Music(activity) Restarts When Rotating Device...why Does It Happen?and How Can I Stop It From Restarting?"