Android Button onClick Media not working

  • Replies:0
AKA
  • Forum posts: 1

Jul 4, 2018, 9:18:34 PM via Website

Button bt = findViewById(R.id.button);
final MediaPlayer mediaPlayer = MediaPlayer.create(invitation1.this, R.raw.sound);
bt.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view) {
mediaPlayer.start();
}
});

— modified on Jul 4, 2018, 9:19:10 PM

Be the first to answer