我正在尝试显示格式为 1.00 分辨率的计数计时器。基本上以秒为单位,分辨率为百分之一秒或 10 毫秒。 我尝试过天文台功能,但还是不行,似乎只能跟踪1秒的分辨率。 这是我的一些代码:
public void stopwatch() {
stopWatch.setOnChronometerTickListener(new OnChronometerTickListener(){
@Override
public void onChronometerTick(Chronometer arg0) {
countUpmilli = (Long) ((SystemClock.elapsedRealtime() -arg0.getBase())/ 100);
countUpSec = (Long) ((SystemClock.elapsedRealtime() -arg0.getBase()) / 1000);
//asText = (countUp / 60) + ":" + (countUp % 60);
asText = (countUpSec / 1) + "." + (countUpmilli%100);
timertext.setText(asText);
}
});
stopWatch.start();
}
最佳答案
我认为你必须使用 System.nanoTime();
关于java - 10毫秒分辨率的定时器android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8110541/