Android sdk & timers (Chronometer vs. Thread)

There are several built-in ways to call a timer using the Android stack. A good example is the Chronometer .

I would like to combine a piece of code (thread A) that implements a timer using the Thread.sleep () method

I plan for the tat service to call this thread and communicate with it.

Are there any drawbacks to using the sleep () method over the chronometer?

+3
source share
1 answer

It depends on whether it is sensitive to the life cycle. If your activity or service is suspended, your timer will be stopped. Take a look at Alarm Manager . There are many examples on this site.

+2
source

Source: https://habr.com/ru/post/1758015/


All Articles