I have an android app where in my Main activity I can play music onCreate(), pause music onPause() and restart music onResume(). I am using MediaPlayer. The problem is that I don't want the music to restart onResume() when I'm rotating the screen on my Main activity. I only want the music to restart when I'm coming back to my Main activity from another activity. Any suggestions?
private MediaPlayer mp;
mp = MediaPlayer.create(MainActivity.this, R.raw.always_sunny); mp.setLooping(true); mp.start();
@Override protected void onPause() { super.onPause(); mp.getCurrentPosition(); mp.pause(); } @Override protected void onResume() { super.onResume(); mp.seekTo(0); mp.start(); }