I'm working on android app where I need to start/ stop the stopwatch even when app is in background. I'm going to use single button for start/stop and 2 buttons only for starting. I'm calling startStopChronometer() method in onClickListener function of button. Also, chronometer is setting to 0 after we recall the function.
public void startStopChronometer(){
if(isStart){
chronometer.stop();
isStart = false;
}else{
chronometer.setBase(SystemClock.elapsedRealtime());
chronometer.start();
isStart = true;
}
}