Using Chronometer Android -
good morning!
i´m trying create chronometer works, when condition in parethesis true, 'stopwatch' started count.. if condition false, textview paused, it's not resuming, because still running in background.. need resumed @ i've stopped..thanks!!
here's dot java code :
if (normaaa>decibelio){
crono.start();//empieza el cronometro } if (normaaa<=decibelio){ crono.stop(); } }
you need define variable wich contains time when chronometer stops:
long timerunning = 0; if (normaaa<=decibelio){ timerunning = systemclock.elapsedrealtime() - chrono.getbase(); crono.stop(); } you use when resume chrono, example function:
void resumechrono(){ crono.setbase(systemclock.elapsedrealtime() - timerunning); crono.start(); } if want completly reset crono , start counting:
void restartcrono(){ crono.setbase(systemclock.elapsedrealtime()); crono.start(); }
Comments
Post a Comment