0

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();
MauroAlexandro
  • 347
  • 3
  • 6
  • 18

2 Answers2

1

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();
MauroAlexandro
  • 347
  • 3
  • 6
  • 18
Ben-J
  • 1,084
  • 8
  • 24
1

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

Bajirao Shinde
  • 1,356
  • 1
  • 18
  • 26