<How to cancel CountdownTImer in Android kotlin?> ...
# stackoverflow
u
How to cancel CountdownTImer in Android kotlin? I want to cancel the timer when user presses the back button or minimizes the app. I have tried using cancel() on 'override fun onDestroy()' but still the timer is running. Below is my countdown timer code countDownTimer = object : CountDownTimer(Constants.timerDuration, 1000) { override fun onTick(millisecondFinished: Long) { binding?.tvTimer?.text = (millisecondFinished / 1000).toString() Log.i("millis", "onTick: $millisecondFinished") }...