i am trying to play sound file on the emulator on click of button but i am getting message \"application play audio has stopped unexpectedly\"
my codes are:
Move the creation of the MediaPlayer instance to the onCreate method.
This will make your application run:
// creating instance of media player
MediaPlayer mp;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mp = MediaPlayer.create(this, R.raw.ljudman__grenade);
Also, if you're trying to start a new instance of your activity upon the button click I believe this is the correct way to do it:
startActivity(new Intent(p1.this, p1.class));