Skip to content
Advertisement

android countdowntimer tick is not accurate

I am using a countdown timer for audio notification… and it’s not accurate from the start…

using initial parameters

JavaScript

I can see in the log that the initial countdown is correctly set to 180000 but the next one should be 120000 and it’s set to 119945 !!!

JavaScript

This is quite annoying as the audio notifier is expecting to say only ‘2 minutes” and not “1 minute and fifty nine seconds” …; why the interval is not right … ? I can tricj it in setting myself the text to speech string … but is there any way to get correct data ?

thanks for suggestions

Advertisement

Answer

I know it’s an old question- but I’ve also encountered the problem, and thought I would share my solution.

Apperantly CountDownTimer isn’t very accurate, so I’ve decided to implement a more percise countdown timer, using java.util.Timer:

JavaScript

Usage example would be:

JavaScript

to start the countdown, simply call countDown.start(). countDown.stop() stops the countDown, which could be restarted using countDown.restart().

Hope this is any help for anyone in the future.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement