Issue
The songs I have are all MediaPlayers, and when I change from horizontal to vertical orientation, or vice versa, the song stops, and then begins playing from the start of the song. I suspect that when i change the layout to horizontal or to vertical that the onPause() method is called or something. What can I do to prevent the song from restarting, and to just keep playing normally when I change from vertical to horizontal and vice versa? Would this have anything to do with the fact that I implemented these methods?
@Override
protected void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
music.get(SongPlaying).stop();
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
music.get(SongPlaying)).stop();
}
@Override
protected void onStop() {
// TODO Auto-generated method stub
super.onStop();
music.get(SongPlaying)).stop();
}
Solution
When you switch orientations, the current activity is destroyed and created again for layout purposes. You can prevent this a few different ways, but throw android:configChanges="orientation" In your activity section of your Manifest file. It should prevent the orientation from restarting the activity
Answered By - Nexion
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.