Answer the question
In order to leave comments, you need to log in
Problems with CountDownTimer?
Hello everyone, I'm trying to figure out the timer, but it works somehow strange, or I don't understand (rather it)
public class MyTimer extends CountDownTimer{
int current_prg = 80;
public GameTimer(long millisInFuture, long countDownInterval) {
super(millisInFuture, countDownInterval);
}
@Override
public void onTick(long l) {
current_prg--;
Log.d("TAG", "TICK "+l+" : "+current_prg);
}
@Override
public void onFinish() {
Log.d("TAG", "FINISH : "+current_prg);
}
}
MyTimer timer = new MyTimer(8000,100);// каждые 100 миллисекунд в течении 8 секунд (80 раз)
timer.start();
Answer the question
In order to leave comments, you need to log in
Since you do not have a real-time system and therefore android switches between tasks (launched applications). As the opportunity arose, so did your method.
You are not guaranteed that it will execute in exactly 100ms, but it is guaranteed that it will not execute before 100ms.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question