When I start the chronometer from another class with the start()
function. It doesn't seem to be starting. It always gives me the beginning value "00:00"
and nothing more.
public class Kronometre {
Context context;
long countUp;
Chronometer stopWatch;
String asText = "00.00";
public Kronometre(Context context) {
this.context = context;
stopWatch = new Chronometer(context);
}
public void start() {
stopWatch.setOnChronometerTickListener(new OnChronometerTickListener(){
@Override
public void onChronometerTick(Chronometer arg0) {
countUp = (SystemClock.elapsedRealtime() - arg0.getBase()) / 1000;
asText = (countUp / 60) + "." + (countUp % 60);
}
});
stopWatch.start();
}
public String getTime() {
return asText;
}
}