Realease the resource MediaPlayer used in the IntroActivity, it was not been released propertly

This commit is contained in:
dtvv 2018-10-02 08:28:52 -05:00
parent fbfa97754f
commit d2e388e5de

View file

@ -54,6 +54,14 @@ public class IntroActivity extends CustomActivity {
@BindView(R.id.btnImportAccount) @BindView(R.id.btnImportAccount)
public Button btnImportAccount; public Button btnImportAccount;
/*
* For the window animation
* */
private MediaPlayer mediaPlayer;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -66,7 +74,7 @@ public class IntroActivity extends CustomActivity {
@Override @Override
public void surfaceCreated(SurfaceHolder surfaceHolder) { public void surfaceCreated(SurfaceHolder surfaceHolder) {
//Log.d(TAG,"surfaceCreated"); //Log.d(TAG,"surfaceCreated");
MediaPlayer mediaPlayer = MediaPlayer.create(IntroActivity.this, R.raw.appbar_background); mediaPlayer = MediaPlayer.create(IntroActivity.this, R.raw.appbar_background);
mediaPlayer.setDisplay(mSurfaceView.getHolder()); mediaPlayer.setDisplay(mSurfaceView.getHolder());
mediaPlayer.setLooping(true); mediaPlayer.setLooping(true);
mediaPlayer.start(); mediaPlayer.start();
@ -148,6 +156,15 @@ public class IntroActivity extends CustomActivity {
startActivity(intent); startActivity(intent);
} }
@Override
protected void onDestroy() {
super.onDestroy();
//Release the media player
mediaPlayer.release();
mediaPlayer = null;
}
@OnClick(R.id.btnImportAccount) @OnClick(R.id.btnImportAccount)
public void importAccount() { public void importAccount() {
FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); FragmentTransaction ft = getSupportFragmentManager().beginTransaction();