Android – How to display timer in activity


I need to display a time duration on a few of my Activities within the application. The timer starts when one of the Activity starts.

  • Should I use service for the timer ?
  • Is this the best way ?
  • Or should I start thread from one of the Activity ?

Best Solution

I think in the use case you're describing it would be best to store time stamps (see Data Storage) and calculate the deltas for GUI use. If you need to display a real-time clock in one of your activities you can create a separate thread in that activity just to update the clock.