I am writing timer application (like the one we use for cooking) for android. I used CountDownTimer to decrease remaining time every second. However, because I am so new at Threads, I didn’t know there was a delay in the timer.
For example, consider simple code using CountDownTimer:
CownDownTimer timer = new CountDownTimer(60 * 1000, 1000) {
public void onTick(long millisUntilFinished) {
System.out.println(millisUntilFinished);
}
}
When I run this, onTick() method should run 60 times, but it doesn’t. Instead, it runs about 57 times. I found out that this is due to delay. What is the most accurate way to write my timer application? Any suggestions? Thanks.
I run this code and on logcat i get 59 entries and I think 1 entry not get because when it you stat timer it wait 1000 milies for first also and then go with onTick(),so the code is working fine
Thanks