When the application turns off or turns off the screen, time stops. Why? Tried three options.

  1. Activity creates a handler and sends it to the service. The service launches Timer . Timer once a second sends its state through the handler (updates TextView in the original Activity ). Those. just "ticking" time in the corner of the screen.

  2. Everything is the same, just not using the Timer class, but just creating a Thread . And the Service starts it. This Thread through the handler updates the Activity element.

  3. I do not create any threads, all the logic in the main thread Service - UI hangs.

Why and how to make it work?

  • show the code so they can help you - artemiygreg

0