question

dersharky-6168 avatar image
0 Votes"
dersharky-6168 asked RobCaplan edited

Which service is better for an timer - background service or foreground service ?

Hi all, I am currently programming an Android app with Xamarin Forms that has a timer and this timer should also work when the display is turned off. After a long research I found out that Xamarin offers two possibilities - foreground service or background service. Disadvantage of background service is that if the system needs more RAM then your app may be turned off or the timer will run slower. Disadvantage of foreground service is that if the system wants to save battery then it can drain resources for your app.

Source: https://proandroiddev.com/android-foreground-service-restrictions-d3baa93b2f70


My question is what is better for a timer: foreground service or background service ?
Is there any other way to run a timer in Xamarin Forms when the display is off?

Thanks to all


dotnet-xamarin
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

If you want to keep the timer alive when going to background , background service is better .

But if you want to keep the timer alive if the application is killed, foreground service is needed .

0 Votes 0 ·

0 Answers