Here you are:
final MediaPlayer sound1 = MediaPlayer.create(this, R.raw.snd1);
final MediaPlayer sound2 = MediaPlayer.create(this, R.raw.snd2);
int sound = 1;
Button play = (Button)findViewById(R.id.button1);
play.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Timer timer = new Timer("click", true);
TimerTask tone = new TimerTask(){
@Override
public void run(){
if (sound % 4 != 0){
sound1.start();
sound += 1;
}else{
sound2.start();
sound = 1;
}
};
timer.scheduleAtFixedRate(tone, 500, 500);
}
});
solved Android – Interchange sounds through timer