A question, maybe a little naive...
If I start a 2 minute CountDownTimer in Activity onCreate() and close it with finish() when user clicks a button, does Android cancel it automatically?
Or do I need to explicitly call cancel() in onDestroy()?
You will have to explicitly call cancel
in Ondestroy
. But better practice is to call cancel
in Onpause
.
Since if you have paused your activity and you update any Ui elements inside OnFinish
of the countdown timer it may throw errors.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With