delay 1 seconds android studio code example
Example 1: how to wait a few seconds in android studio
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
public void run() {
// yourMethod();
}
}, 5000); //5 seconds
Example 2: android studio delay
new CountDownTimer(30000, 1000) {
public void onTick(long millisUntilFinished) {
mTextField.setText("seconds remaining: " + millisUntilFinished / 1000);
}
public void onFinish() {
mTextField.setText("done!");
}
}.start();