Common constructors:
CountDownTimer(long millisInFuture, long countDownInterval)
Common methods:
final void cancel()
Cancel the countdown.
abstract void onFinish()
Callback fired when the time is up.
abstract void onTick(long millisUntilFinished)
Callback fired on regular interval.
synchronized final CountDownTimer start()
Start the countdown.
Common constructors:
public CountDownTimer (long millisInFuture, long countDownInterval)
Parameters
1. millisInFuture The number of millis in the future from the call to start() until the countdown is done and onFinish() is called.
2. countDownInterval The interval along the way to receive onTick(long) callbacks.
Common methods:
public final void cancel ()
Cancel the countdown.
public abstract void onFinish ()
Callback fired when the time is up.
public abstract void onTick (long millisUntilFinished)
Callback fired on regular interval.
Parameters: millisUntilFinished The amount of time until finished.
public final synchronized CountDownTimer start ()
Start the countdown.
Links to textbooks:
reference 1
reference 2
reference 3
Edit:
new CountDownTimer(30000 , 1000 ) {
public void onTick(long millisUntilFinished) {
Log.i("Countdown Timer: ","seconds remaining: " + millisUntilFinished / 1000);
}
public void onFinish() {
myTextView.setText("Time Out.!");
}
}.start();
source
share