java - create simple timer android -
i want make simple timer time how long takes user in app. have in mind start timer, stop timer , display time. have been searching , haven't found definitive solution works. simple envision or more complicated have found searching?
how precise timer need be?
the simplest way take time before performing task , subtract time after performing task:
long start = system.currenttimemillis(); // task long timetakenms = system.currenttimemillis() - start;
if mean user-event-driven timer, can apply same principles above:
// declare instance variable long start = 0l; // onstarttimer start = system.currenttimemillis(); // onstoptimer long elapsed = system.currenttimemillis() - start;
Comments
Post a Comment