I have 2 CountDownTimer objects in my app, that count the time to next event constantly as the app is running.
So today I debugged it, and found out that the timer is not accurate at all, I have given it an interval of 1 hour, starting at 9:00 am, and now 14:04 was when the next event fired. whole 4 mins late, and it is getting more and more with each event.
So should I use the CountDownTimer for such task, or I should just make an if check in it's onTick()
method, where every second I will check for fixed time passed since the previous event, then reset the time for after 1 hour?
I can't do these tasks with AlarmManager, since all these things are happening in foreground service
, and as much as I know, Alarms will be killed if the users swipes the app away from the running apps menu