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)
public Button btnImportAccount;
/*
* For the window animation
* */
private MediaPlayer mediaPlayer;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -66,7 +74,7 @@ public class IntroActivity extends CustomActivity {
@Override
public void surfaceCreated(SurfaceHolder surfaceHolder) {
//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.setLooping(true);
mediaPlayer.start();
@ -148,6 +156,15 @@ public class IntroActivity extends CustomActivity {
startActivity(intent);
}
@Override
protected void onDestroy() {
super.onDestroy();
//Release the media player
mediaPlayer.release();
mediaPlayer = null;
}
@OnClick(R.id.btnImportAccount)
public void importAccount() {
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();