tags:

views:

38

answers:

2

Hello, another new problem described below:

When I press home button when music STILL plays, it closes correctly, but when the sound (that is five seconds long) has finished and I press home button, it gives me a force close. I have tried an else-statement; with no luck.

protected void onStop() {
    super.onStop();
    if(mp.isPlaying()){
        mp.pause();
    }
}

there my variable mp is a MediaPlayer linked to this mp = MediaPlayer.create(getBaseContext(), R.raw.mainsound);

Ideas?

A: 

Is there some code elsewhere that nulls out mp when it finishes playing?

Curtis
Yes, there my exit-button is located to exit the application.
Julian Assange
A: 

It seems that I solved it. I had a setOnCompletionListener inside my onCreate which lead to I couldn't access my mp, when it stopped.

Julian Assange