I have an application with xamarin essentials. This takes the information every 5 seconds with a waiting time of 3 seconds of GPS
Device.StartTimer(TimeSpan.FromMilliseconds(Timmer), () => { RunPoint(); return isRunningTimer; });
public async void RunPoint()
{ try
{
DateTime dateLanch = DateTime.Now;
var request = new GeolocationRequest(accuracy, TimeSpan.FromSeconds(TimeOutGps));
var location = await Geolocation.GetLocationAsync(request);
if (location != null)
{
point = new GPSPoint
{
Status = StatusGPS.OK,
Point = new Cerezasoft.Geo.Points.Point { Latitude = location.Latitude, Longitude = location.Longitude },
Stamp = location.Timestamp.LocalDateTime,
StampSystem = DateTime.Now,
StampLanch = dateLanch,
StampUniversal = location.Timestamp.UtcDateTime,
Speed = 0,
SpeedGPS = location.Speed.HasValue ? location.Speed.Value : 0,
Elevation = location.Altitude.HasValue ? location.Altitude.Value : 0
};
}
else
{
point.Status = StatusGPS.ErrorCalculo;
}
}
catch (FeatureNotSupportedException fnsEx)
{
point.Status = StatusGPSRallySystem.NoSensor;
point.MessageError = fnsEx.Message;
}
catch (PermissionException pEx)
{
point.Status = StatusGPS.NoAcces;
point.MessageError = pEx.Message;
}
catch (Exception ex)
{
point.Status = StatusGPS.ErrorSensor;
point.MessageError = ex.Message;
}
}
when application use with another application with gps. The capture of gps information works very well but if you execute the precision and the quality of the data, the location becomes erratic.
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-feature android:name="android.hardware.location" android:required="false" />
<uses-feature android:name="android.hardware.location.gps" android:required="true" />
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
Xamarin.Essentials.Platform.Init(this, savedInstanceState);
}
I do a comparison with another app in split screen and it works fine. when my app works alone, the operating system returns the position in a different way. when my app runs by itself. the operating system returns the position more erratically.both tests are carried out in the same place with the same conditions and the same cell phone. I do not know what services and what additional elements are activating the other app for the optimal functioning of the gps
Thanks for the collaboration
"I do a comparison with another app in split screen and it works fine. when my app works alone, the operating system returns the position in a different way. when my app runs by itself. the operating system returns the position more erratically."
I am running into the exact same issue as explained above
This is my code
locator = CrossGeolocator.Current;
if (locator.IsGeolocationAvailable && locator.IsGeolocationEnabled)
{
locator.DesiredAccuracy = 10;
await locator.StartListeningAsync(TimeSpan.FromSeconds(15), 10, false, new Plugin.Geolocator.Abstractions.ListenerSettings()
{
AllowBackgroundUpdates = true,
ActivityType = Plugin.Geolocator.Abstractions.ActivityType.Fitness,
PauseLocationUpdatesAutomatically = false
});
locator.PositionChanged += Postion_Changed;
}
public void Postion_Changed(object sender, Plugin.Geolocator.Abstractions.PositionEventArgs e)
{
if (e.Position.Accuracy < 75)
{
LocationService.SaveGpsLocation(e.Position.Latitude, e.Position.Longitude, e.Position.Timestamp.DateTime);
}
}
When running it with another GPS app it's pinpoint accurate, but when running alone it jumps around A LOT.
"I presume the other app has done some custom "filtering", their own code, to get a more stable result. There is no "simple" answer anyone can tell you, AFAIK. Hence my links above."
This cannot be true, because that would not affect our apps at all. They are simply managing to request a much finer location which in turn helps our app somehow - we are just trying to figure out why.