0

I need to use postDelayed() method inside onFinish() method of the CountDownTimer. I use the following code:

...
public void onFinish() {
  Handler handler = new Handler();
  handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                //do something here after 3 seconds
            }
        }, 3000);
}

But it does not work. It does not delay.

Mike087
  • 486
  • 3
  • 13

1 Answers1

1

It's not going to work. You will have to find another way to accomplish your goal. The reason why, is because your post delayed is ran on a different thread then the onFinish. onFinish will run on the UI tread. After onFinish is ran the class will be closed out and the postDelayed thread will be no more.

Drivers Sea
  • 446
  • 2
  • 10