Is it possible to stop the ForegroundService Launched by GpsDelegate when app closes #1600
|
I'm currently using the latest release of Shiny.Locations (3.3.4). I'm using a GpsManager and my GpsDelegate to listen for gps readings in the background. Everything is working exactly as I was hoping except, on the Android platform, I've not found a way to insure that the ForegroundService is stopped when the application has been closed. Any help would be appreciated. Thank you. |
Replies: 1 comment
|
Closed as in the user swiped away the app? If so, Android doesn't close foreground services on your behalf. To make matters worse, there isn't a way to reliably check if an android app is even being closed. I do have a variable you can set that will try to shutdown the foreground service, but it unfortunately is not guaranteed to work on all flavours of Android. I don't set this as a default value since it is not the default android behaviour. #if ANDROID
await GpsManager.StartListener(new AndroidGpsRequest
{
... your other settings
StopForegroundServiceWithTask = true
}); |
Closed as in the user swiped away the app? If so, Android doesn't close foreground services on your behalf. To make matters worse, there isn't a way to reliably check if an android app is even being closed. I do have a variable you can set that will try to shutdown the foreground service, but it unfortunately is not guaranteed to work on all flavours of Android. I don't set this as a default value since it is not the default android behaviour.