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

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -