I to restart a CountDownTimer. I read a lot of question here but no one of the answer helped me. When I use the following code
if(Const.counter != null){
private fun startTimer() {
var timeInMilliSeconds = 11000L
val countDownTimer: CountDownTimer = object : CountDownTimer(timeInMilliSeconds, 1000) {
override fun onFinish() {
Timber.d("Times Up!")
setupResult("")
this.cancel()
timeInMilliSeconds = 11000L
this.start()
}
override fun onTick(p0: Long) {
val seconds = (p0 / 1000) % 60
Timber.d("Timer: $p0")
timer?.text = "$seconds"
}
}
countDownTimer.start()
}