Android timer skipping numbers regularly -


i have android countdown timer inconsistent, , doesn't update gui regularly or correctly.

public boolean btimerrunning = false; public countdowntimer timer; private long currenttime = 180000;  public void ontimertap(view v) {      if (btimerrunning) {         //stop timer         timer.cancel();         btimerrunning = false;      } else {         //start timer         final textview ettime = (textview) findviewbyid(r.id.tvtimer);          //initalize timer         timer = new countdowntimer(currenttime, 1000) {             int secondsleft = 0;             @override             public void ontick(long millisuntilfinished) {                  string currenttimestr = string.format("%d:%02d",                         timeunit.milliseconds.tominutes(millisuntilfinished),                         timeunit.milliseconds.toseconds(millisuntilfinished) -                                 timeunit.minutes.toseconds(timeunit.milliseconds.tominutes(millisuntilfinished))                 );                  //save value "pause" timer                 currenttime = millisuntilfinished;                  //show on text                 ettime.settext(currenttimestr);             }              @override             public void onfinish() {             }         };          timer.start();         //set boolean         btimerrunning = true;     }      } 

from have seen in past questions, typical last few seconds of timer, i'm seeing in first few ticks, or in middle. how can make timer better ticker? narrowing down tick time work , rounding?


Comments