On Fri, Feb 17, 2012 at 3:14 PM, exax <[email protected]> wrote:
> So, I wanted to create a simple sound player that will just play a
> sound when I touch a button. I created it without errors but it
> crashes everytime i run it. I got rid of all the extra code and found
> that the error is coming from the media player initialization
>
> public MediaPlayer music = MediaPlayer.create
> (getApplicationContext(), R.raw.sound_1);
>
> I believe this is due to my lack of understanding context. i need some
> help figuring out what context to put into the first parameter.

Try:

public MediaPlayer music = MediaPlayer.create(this, R.raw.sound_1);

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Warescription: Three Android Books, Plus Updates, One Low Price!

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to