Question

I made an android app that plays the mario sound when you jump. It works fine (sort of), but when I close it, it still works. I tried using the onDestroy method, but it dosen't seem to delete the objects I created or something...

here is the code. http://pastebin.com/GCkrBkv9

Was it helpful?

Solution

Try putting your code to stop the playing inside onPause() instead of onDestroy() like so:

@Override
public void onPause() {
        super.onPause();
        sp.stop(jump);
        sp.release();
}

It's quite possible that the activity is not yet destroyed and just sent to the background, so onDestroy() is not yet called even if you "close" the app.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top