location-samples
location-samples copied to clipboard
LocationUpdatesForegroundService Sample not retrieving location under background and Battery Optimization
https://docs.microsoft.com/en-us/samples/xamarin/monodroid-samples/android-o-androidplaylocation-locupdfgservice/
I downloaded this sample and printed location data from the OnLocationChange event. I am discovering that the sample (APP) works great and successfully write location data even while APP is in background (Screen Off) and Battery Optimization is OFF.
Unfortunately, when APP is in background (Screen OFF) and the Battery Optimization has been turned ON, then there is no location data written to output file.
Even if I put the APP in BatterySaver Optimization WhiteList, the data is not written.
I tried
intent.SetAction(Android.Provider.Settings.ActionIgnoreBatteryOptimizationSettings);
but without success
How can I get the location when the APP is running in the Background and the screen is turned OFF and BatterySaver Optimization is turned ON ?
Did you find any solution?
I wind up using WakeLock. For battery optimization I release it. Its not a very efficient solution and I am still in need for a better solution!