0

The app is a sports timer for cycling, skiing etc, where racers start at regular intervals. e.g. 1 minute.

In my implementation of OnChronometerTickListener I notice that the calls occur at intervals significantly longer than 1000 mS. I use the elapsed time (between the Tick and the Chronometer's base) to count down the last 5 seconds for each interval. Due to the late callback, I can get ticks at, say, 55,500 56,600 57,750 58,870 59,980 61,110

I can therefor skip a whole second when I use m_Elapsed % 1000. I have even seen the text in the Chronometer get behind and have to skip a second. I have no problem with accuracy when I do calculations based on the Chronometer's base time and current system time.

Do I have to write my own Chronometer using finer callbacks? Or is there some other fix?

BryanT
  • 412
  • 3
  • 12
  • chronometer sends messages delayed with 1000 ms hence you see such behavior, you could use own class that uses Handler that posts with finer delay – pskink Apr 29 '13 at 13:33
  • Should have said "racers" not r"races". – BryanT Apr 29 '13 at 16:03
  • I see now that Chronometer does not do the equivalent of "scheduleAtFixedRate". I worked around by using Timer's scheduleAtFixedRate() and a TimerTask. For this I also had to learn how to use a Handler (as pskink suggested) because the TimerTask runs in a thread separate from my GUI / Activity. Now the Chronometer and my count down can drift apart. I may abandon the Chronometer and use my same "tacks" for both. It's only the on screen display. Any race results I capture are accurate. – BryanT Nov 14 '13 at 00:48
  • @BryanT Have you found solution to this issue ? I am facing the same issue now. – Rakesh L Oct 14 '20 at 13:10

0 Answers0