Whiz Whiz - 3 months ago 14x
Android Question

How do I start chronometer with a specific starting time?

Let's say I have this variable:

long myMillis = 20000;

This means that I want my Chronometer to start at exactly 20 seconds (00:20).

I tried doing this:


But it doesn't work. It dosn't start with 20 seconds. It starts with some weird time that doesn't make sense.


In general the chronometer works like this (if you would like to set the Base to a specific nr):

mChronometer.setBase(SystemClock.elapsedRealtime() - (nr_of_min * 60000 + nr_of_sec * 1000)))

so make it:

 mChronometer.setBase(SystemClock.elapsedRealtime() - (2* 60000 + 0 * 1000)))