I have a button and when it is pressed it plays an audio file. I want to put a 5 second delay on the button so users wont mash the button and play the sound over and over. I
You can disable your button, then use the postDelayed method on your button.
myButton.setEnabled(false);
myButton.postDelayed(new Runnable() {
@Override
public void run() {
myButton.setEnabled(true);
}
}, 5000);
This is similar to the Timer solution, but it might better handle configuration change (for example if the user rotate the phone)