当我在活动之间切换时,如何在此代码中保存Mediaplayer的状态
on = findViewById(R.id.on);
final MediaPlayer mp = MediaPlayer.create(MainActivity.this, R.raw.simba);
mp.start();
on.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mp.isPlaying()) {
mp.pause();
on.setBackgroundResource(R.drawable.off);
} else {
mp.start();
on.setBackgroundResource(R.drawable.on);
}
}
});