Skip to content Skip to sidebar Skip to footer

Countdowntimer In Android Using Java

I am trying to implement a timer in android. I am using the countdowntimer. Here, is the timer code: new CountDownTimer(totalTime * 1000, 1000) { @Override public

Solution 1:

As shown in the CountDownTimer documentation

onTick(long millisUntilFinished)

millisUntilFinished long: The amount of time until finished.

Which means that 00:00 won't ever be shown in your code because the onTick won't be called when there is no time left to be finished.

Simply you have to show the 00:00 inside onFinish

@OverridepublicvoidonFinish() {
            tv_timer.setText("00:00");
            mediaPlayer.start();
        }

About the alarm tone, seems that it rings immediately after the count down is finished. You have to check that the tone itself doesn't have a silent one or two seconds in the beginning.

Post a Comment for "Countdowntimer In Android Using Java"