Hi,
We are developing Xamarin.Forms application. In Android project we have added a sticky service and BroadcastReceiver. In Service we are using Alarm Manager to schedule a notification. Code to show notification is written in Service. Everything works fine when the application active or in background or phone is locked. Once I close the application (swipe left from recent apps) the service stop working. Since it's sticky service, it tries to restart itself but it show error message twice that service has stopped working. I have tried all below option but not able to keep running the service:
- Used Android App Context instead of Forms.Context
- Tried invoking service as IsolatedProcess
- Tries to start service by custom Android Application class so it starts from another thread and not the UI thread
I have searched everywhere and did not find any implementation for sticky service using Xamarin.Forms. I have read forums where people have posted same query but there seems to be no solution for Xamarin.Forms. Also will Broadcast receiver work when it's scheduled from Service and application is closed. I have seen lot of examples where this scenario works in Android project but no where I see solution for Xamarin.Forms.
Quick suggestions will be appreciated. I can share some code if required.
Thanks
Mohit