Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

Android Sticky service and BroadcastReceiver not working when Xamarin.Forms application is closed

$
0
0

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:

  1. Used Android App Context instead of Forms.Context
  2. Tried invoking service as IsolatedProcess
  3. 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


Viewing all articles
Browse latest Browse all 91519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>