I am using MediaPlayer to play some sound in my app, I want this playback to stop when user leaves activity in which sound is being played. So I did this by calling mediaplayer.stop() in my activities onStop() method.
public void onStop() {
super.onDestroy();
mediaPlayer.stop();
mediaPlayer.reset();
}
but now when device rotation changes even then sound playback stops,because onStop() method is called, which I don't want, playback should continue when device orientation changes. How can this be done.
只需将此ligne添加到您要解决的<Activity>
Manifest.xml
:
android:configChanges="keyboardHidden|orientation|screenSize"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.