Plugin.Geolocator (partially) uses coarse locations in Android 12

180 Views Asked by At

I have a tracking app which uses Plugin.Geolocator (4.6.2-beta) to sample locations, as the user moves. This worked perfectly until upgrading to android 12. Now it jumps from the true location to nearby wifi locations and then back to true gps postions and so on, while tracking inside a city.

The app is requesting, and the user allows, fine location. It generally works, but every so often the location jumps abruptly to a nearby house before returning to true location.

var l = new Plugin.Geolocator.Abstractions.ListenerSettings
{
  AllowBackgroundUpdates = true,
  ActivityType = Plugin.Geolocator.Abstractions.ActivityType.AutomotiveNavigation,
  PauseLocationUpdatesAutomatically = false,
  ShowsBackgroundLocationIndicator = false
};
CrossGeolocator.Current.DesiredAccuracy = 1;
CrossGeolocator.Current.PositionChanged += Current_PositionChanged;
CrossGeolocator.Current.StartListeningAsync(TimeSpan.FromSeconds(1), 0, true, l);

enter image description here

1

There are 1 best solutions below

0
On

It is unclear why it happens, but I will close this with "it is what it is". Where Plugin.Geolocator uses network location (now and then) given the setup, I described in the question, using the fused location provider in android (still did not make an iOS implementation) has no such issue, so supposedly Plugin.Geolocator is simply outdated and in need of an update.

Fused location provider in Android with these settings work flawlessly

LocationRequest locationRequest = LocationRequest.Create()
                            .SetPriority(LocationRequest.PriorityHighAccuracy)
                            .SetInterval(1000)
                            .SetFastestInterval(1000);

And its use is described well enough here https://learn.microsoft.com/en-us/xamarin/android/platform/maps-and-location/location