Android MediaPlayer crashing app

Posted by user1555863 on Stack Overflow See other posts from Stack Overflow or by user1555863
Published on 2012-09-06T15:28:53Z Indexed on 2012/09/06 15:38 UTC
Read the original article Hit count: 325

Filed under:

I have an android app with a button that plays a sound. the code for playing the sound:

if (mp != null)
            {
                mp.release();
            }
            mp = MediaPlayer.create(this, R.raw.match);
            mp.start();

mp is a field in the activity:

public class Game extends Activity implements OnClickListener {
/** Called when the activity is first created. */
//variables:
MediaPlayer mp;
//...

The app runs ok, but after clicking the button about 200 times on the emulator, app crashed and gave me this error https://dl.dropbox.com/u/5488790/error.txt (couldn't figure how to post it here so it will appear decently)
i am assuming this is because the MediaPlayer object is consuming up too much memory, but isn't mp.release() supposed to take care of this? What am i doing wrong here?

© Stack Overflow or respective owner

Related posts about android