Héctor
Héctor

Reputation: 26034

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.

Upvotes: 3

Views: 92

Answers (1)

IntelliJ Amiya
IntelliJ Amiya

Reputation: 75788

Need Subtraction instead of Addition.

You should try with

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

Upvotes: 2

Related Questions