0

I need a reliable way to monitor minute-ticks in an Android app. This thread (in C#) .NET, event every minute (on the minute). Is a timer the best option? says that creating a timer that ticks every second and within that event, checking if a minute has gone by, adds negligible overhead to a C# application.

Is the same approach in Android feasible? Or are there other ways to do it?

Community
  • 1
  • 1
Renault
  • 1
  • 1

2 Answers2

1

You can also create a Timer that fires at a given time:

Timer timer = new Timer();
long fireAt = System.currentTimeMillis() + 60000;
timer.schedule(new TimerTask(),new Date(fireAt));
nhaarman
  • 98,571
  • 55
  • 246
  • 278
  • That works perfect for *one* call, but if you want to have a **reliable** tick **every** minute, you will end up with a very noticeable drifting scheduling timers at every run. – Aleadam May 30 '11 at 21:17
0

Yes. You can use the Chronometer View.

Aleadam
  • 40,203
  • 9
  • 86
  • 108