location-samples icon indicating copy to clipboard operation
location-samples copied to clipboard

LocationUpdatesForegroundService Sample not retrieving location under background and Battery Optimization

Open GolfMan2000 opened this issue 4 years ago • 2 comments

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 ?

GolfMan2000 avatar Jun 22 '20 18:06 GolfMan2000

Did you find any solution?

bsalponia avatar Dec 12 '20 23:12 bsalponia

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!

GolfMan2000 avatar Dec 13 '20 08:12 GolfMan2000