I have implemented the timer functionality in android app, I able to finish the timer from other local methods by calling timerObject.cancel()
. Its working perfect
Looking at the source code for CountDownTimer
it is easy to see why it is not working. cancel()
merely removes the message for ticking the timer from the queue. But the message handler that gets called at each tick posts a message for the next tick after calling onTick()
. So either you have to call cancel()
outside of onTick()
, via a Handler
for example, or switch to using the Timer class instead.