kaarido
kaarido

Reputation: 3

CountDownTimer strange Finish behaviour

When Timer Finish it goes back to previous Activity for a Second then Apply onFinish What is the reason and how to prevent that.

mCountDownTimer = new CountDownTimer(mTimeLeftInMillis, 1000) {
    @Override
    public void onTick(long millisUntilFinished) {
        mTimeLeftInMillis = millisUntilFinished;
        updateCountDownText();
    }

    @Override
    public void onFinish() {
        playAgain();
    }
}.start();

Upvotes: 0

Views: 77

Answers (1)

Nima Ganji
Nima Ganji

Reputation: 601

The Reseaon is at the start of every tick, before onTick() is called, the remaining time until the end of the countdown is calculated and If this time is smaller than the countdown time interval, onTick() would not not called anymore. When onTick() called CountDownTimer consume some time for calculation. the easiest way to handle this is to add some extra timeLeftInMillis to your timer!

Upvotes: 1

Related Questions