S
S
Sergey2018-05-29 15:58:20
Android
Sergey, 2018-05-29 15:58:20

Why is the stopwatch made on the handler in android behind?

Made a stopwatch. The basis of his handler. The algorithm is like this.
handler.post(new Runnable(){
public void run(){
second++
//here I update the view by inserting the second variable into it
handler.postDelayed(this, 1000);
}
});
Essence of the question. As long as the interval is 1000 milliseconds, everything is fine. As soon as I do less than 500, the stopwatch starts to lag behind. At what on 100 milliseconds lags behind 1 second per minute. Broke my whole head. How to make accuracy normal? And if it is not possible to do this on the handler, what can be used instead?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question