How to make CountDownTimer count to 1?

Michael Romanchuk :

How do I make CountDownTimer count to 1, not 0? How do I do that? ( ͡° ͜ʖ ͡°)

    private void start() {

    countDownTimer = new CountDownTimer(3000, 1000) {
        @Override
        public void onTick(long millisUntilFinished) {
            time.setText("" + millisUntilFinished / 1000);

        }

        @Override
        public void onFinish() {
            time.setText("Click!");
        }
    };

    countDownTimer.start();
}
Gokul Nath KP :

Instead of starting from 4000 ms, start from 3000 ms, and add +1 before setting to TextView:

private void start() {

    countDownTimer = new CountDownTimer(3000, 1000) {
        @Override
        public void onTick(long millisUntilFinished) {
            time.setText(String.valueOf((int) Math.ceil(millisUntilFinished / 1000.0)));
        }

        @Override
        public void onFinish() {
            time.setText("Click!");
        }
    };

    countDownTimer.start();
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=110315&siteId=1