Reputation: 367
I am wondering if this is the best way to make a timer of 1 minute on Android:
new CountDownTimer(60000, 1000) {
public void onTick(long millisUntilFinished) {
}
public void onFinish() {
}
}.start();
Upvotes: 0
Views: 89
Reputation: 1125
You don't need to use the onTick():
new CountDownTimer(60000, 60000) {
public void onTick(long millisUntilFinished) {
}
public void onFinish() {
//do your stuff here
}
}.start();
Upvotes: 1
Reputation: 1354
This is the easy and very simple way
new CountDownTimer(30000, 1000) {
public void onTick(long millisUntilFinished) {
mTextField.setText("seconds remaining: " + millisUntilFinished / 1000);
}
public void onFinish() {
mTextField.setText("done!");
}
}.start();
for more info see this link
Upvotes: 1