Tal Malka
Tal Malka

Reputation: 13

Waiting for a countdowntimer to finish

I need help with writing a code,

How do I make a code to wait until the countdown timer is finished?

I tried with boolean says if countdown timer is running and in the code, it was like this:

---part 1 of code---

While(running){}

---part2 of the code---

It makes the screen freeze... Idk how to solve this.. help someone?

Upvotes: 0

Views: 428

Answers (1)

haliltprkk
haliltprkk

Reputation: 1508

CountDownTimer already has that, You just need to put the codes that you want to make them work after the timer finished, inside the onFinish(), like below

 countDownTimer = new CountDownTimer(10000, 1000) {
        @Override
        public void onTick(long l) {

        }

        @Override
        public void onFinish() {
          //this part will work after timer have finished
        }
    }.start();

Upvotes: 1

Related Questions