Hello
For an app like a stopwatch, I need a timer that does not stop when the smartphone goes to sleep (screen off).
I understood that I had to launch a service to create the timer, but the problem is that it stops about 30 seconds after the smartphone goes to sleep.
I read that I had to write instructions like Service.AutomaticForegroundMode=Service.AUTOMATIC_FOREGROUND_ALWAYS but it doesn't solve my problem.
In fact I didn't really understand what to do, so I'm looking for an example.
Thanks for your help.
For an app like a stopwatch, I need a timer that does not stop when the smartphone goes to sleep (screen off).
I understood that I had to launch a service to create the timer, but the problem is that it stops about 30 seconds after the smartphone goes to sleep.
I read that I had to write instructions like Service.AutomaticForegroundMode=Service.AUTOMATIC_FOREGROUND_ALWAYS but it doesn't solve my problem.
In fact I didn't really understand what to do, so I'm looking for an example.
Thanks for your help.