Hi there, I have implemented a launcher using Xamarin Android. I would like to listen to system notifications even when the device is in sleep mode. Do I need to implement it using some kind of background service, or is there a simpler way to do it.
Hi there, I have implemented a launcher using Xamarin Android. I would like to listen to system notifications even when the device is in sleep mode. Do I need to implement it using some kind of background service, or is there a simpler way to do it.
Hello,
Welcome to our Microsoft Q&A platform!
Hi, khatauli-9225. Starting in Android 8.0 (API level 26), an Android application no longer have the ability to run freely in the background. When an application moves into the background, Android will grant the app a certain amount of time to start and use services. Once that time has elapsed, the app can no longer start any services and any services that were started will be terminated.
To perform a background task for a long time, try using a foreground service instead.
Check the doc: https://docs.microsoft.com/en-us/xamarin/android/app-fundamentals/services/foreground-services
Similar issue: https://stackoverflow.com/questions/58107522/how-to-create-a-never-ending-background-service-in-xamarin-forms
Best Regards,
Jarvan Zhang
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
5 people are following this question.