I mm trying to create a resume button in my Android app using Chronometer. So far I have this code snippet for the resume method:
private long pauseResume() {
long timeWhenStopped = chronometer.getBase() - SystemClock.elapsedRealtime();
return timeWhenStopped;
}
And here's the code for the resume button:
public void onClick(View v) {
switch(v.getId()) {
...
case R.id.resume_button:
chronometer.setBase(SystemClock.elapsedRealtime() + pauseResume());
chronometer.start();
break;
}
}
THE PROBLEM: Example, when I pause the timer at 00:05 and then I press the resume button 10 seconds later, the timer will resume counting at 00:15.
I want it to start at 00:05 again, not 00:15, because as it is a "resume" function.
I am very glad you could help. Thanks.