Search code examples
androidchronometer

Resume Chronometer from given minutes


I have a Chronometer and a int variable representing the accumulated minutes when it was stoped. I want to resume the chronometer from these minutes.

int accumulatedMinutes = 2;
chronometer.setBase(SystemClock.elapsedRealtime() + accumulatedMinutes*60000);

But, in the case above, instead of 02:00, I get 00:-120

Thanks.


Solution

  • Need Subtraction instead of Addition.

    You should try with

    chronometer.setBase(SystemClock.elapsedRealtime() - accumulatedMinutes*60000);