Best way to implement Timer in Android? -
i doing math game, , have 25 question user answer. so, want mesaure how time user needed solving that?
so need timer, stopwatch ability pause time when user click on button.
i saw few implementations chronometer, task?
if looking figure out how long user took don't need use special object honestly.
just make long variable , store starttime system.getcurrenttimeinmillis();
long starttime = system.currenttimemillis(); //do problems here long endtime = system.currenttimemillis(); long totaltime = endtime - starttime; log.i("tag", "it took "+ totaltime / 1000 + " seconds complete problems");
to pausing you'll need long tracks how long paused , subtract totaltime.
Comments
Post a Comment