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

This commit is contained in:
dtvv 2018-10-02 08:16:36 -05:00
parent 94267c6cc3
commit fbfa97754f

View file

@ -98,6 +98,14 @@ public class BoardActivity extends CustomActivity {
File photoDirectory; File photoDirectory;
/*
* 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);
@ -170,7 +178,7 @@ public class BoardActivity 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(BoardActivity.this, R.raw.appbar_background); mediaPlayer = MediaPlayer.create(BoardActivity.this, R.raw.appbar_background);
mediaPlayer.setDisplay(mSurfaceView.getHolder()); mediaPlayer.setDisplay(mSurfaceView.getHolder());
mediaPlayer.setLooping(true); mediaPlayer.setLooping(true);
mediaPlayer.start(); mediaPlayer.start();
@ -271,6 +279,15 @@ public class BoardActivity extends CustomActivity {
loadUserImage(); loadUserImage();
} }
@Override
protected void onDestroy() {
super.onDestroy();
//Release the media player
mediaPlayer.release();
mediaPlayer = null;
}
public void loadUserImage(){ public void loadUserImage(){
//Search for a existing photo //Search for a existing photo
File photoFile = new File(photoDirectory + File.separator + "photo.png"); File photoFile = new File(photoDirectory + File.separator + "photo.png");