4
How can I create a button with Soundeffect using the Mediaplayer class or any other android class?
I tried using the following code I found some examples, but I was not successful.
public void playMusic(){
    if(player == null){
        try {
            player = MediaPlayer.create(TelaJogoSingle.this, R.raw.song1);
            player.start();
        }
        catch (IllegalArgumentException e) { e.printStackTrace(); }
        catch (SecurityException e) { e.printStackTrace(); }
        catch (IllegalStateException e) { e.printStackTrace(); }
    }else{
        player.start();
    }
}
						
You want, by clicking a button, to produce a sound?
– ramaral
yes, a sound 1 second long +-.
– Kallan