Open lukikoli opened 1 year ago
What phones are these tested on? There are not any conditional statements between Android 11/13, so I doubt this is a bug with the code. Just a quick Google search, there are other people that have had previous issues with GPS on Android 13. You could also test other apps to see if you notice a difference as well.
Hi, I tested it on a virtualized Google Pixel 5 Android 13. I googled the problem online and there are many other people, that have the same problem that I have. I couldn't find any solution. That's why I need your help. Thanks
I not sure what you have tried already. It could be that the almanac need redownloaded. This can happen by letting the gps sit for about 10-15 minutes to acquire satellites. https://www.reddit.com/r/GooglePixel/comments/wt3tms/gps_problem_with_a13_update_on_pixel_5/
Hi, I just tested my app on Android 13, there it's working fine. Allthough, the location still glitches arround in a distance of like 15 meters. I want to track the location and display the route on a track so this is a big problem
I implemented the Code as follows: I have a foreground service that starts subscribing to the CrossGeolocator PosChanged event. (Can I even implement it like that on Android?)
My Code:
`public async void OnServiceStarted() {
//REGISTER GPS Service CrossGeolocator
try
{
if (CrossGeolocator.Current.IsListening)
return;
await CrossGeolocator.Current.StartListeningAsync(TimeSpan.FromSeconds(2), 10, true, new GeolocatorPlugin.Abstractions.ListenerSettings
{
ActivityType = GeolocatorPlugin.Abstractions.ActivityType.AutomotiveNavigation,
AllowBackgroundUpdates = true,
DeferLocationUpdates = true,
DeferralDistanceMeters = 10,
DeferralTime = TimeSpan.FromSeconds(2),
ListenForSignificantChanges = true,
PauseLocationUpdatesAutomatically = false
});
CrossGeolocator.Current.PositionChanged += PosChanged;
CrossGeolocator.Current.PositionError += PosError;
}
catch(Exception e) {
System.Diagnostics.Debug.WriteLine("Service NOT RUNNING ANYMORE " + e);
}
}`
Then if the position changes, I will just save these values in an array of Locations.
That should work. I added a Sample project. You can double check with it if you run into problems. https://github.com/gktval/Maui-GeolocatorPlugin/tree/main/Sample
Allthough, the location still glitches arround in a distance of like 15 meters.
Check your horizontal accuracy. A good accuracy for a phone GPS should be less than 10. Otherwise, also check if you are around tall buildings or trees as this will affect the accuracy.
An alternative solution is to create a circular list that takes a weighted running average of the last 5 points or so. Other options include Kalman Filters or kicking out bad data.
Me same issue here. 1 of 5 locations changed arguments is San Francisco which far away from current location.
Also PositionChanged event fires to many times.
Confirmed build in Geolocation
class works as expected.
I use this code
var status = await Permissions.RequestAsync
private static async void CrossGeolocator_Current_PositionChanged(object sender, PositionEventArgs e) { try { await BaseService.AddNewAttendanceLocationTracking(new AttendanceLocationTrackingModel() { AttendanceId = AttendanceId, UserId = long.Parse(Settings.UserId), Latitude = e.Position.Latitude, Longitude = e.Position.Longitude, }); }
PositionChanged event fires to many times and return same latitude and longitude althougth i am don't move ??
is there any soultion for this issue
i use this solution and working fine now PositionChanged only fire if latitude and longitude changed
private static async void CrossGeolocator_Current_PositionChanged(object sender, PositionEventArgs e) { var currentPosition = e.Position;
// Check if the position has significantly changed
if (_lastPosition != null &&
Math.Abs(_lastPosition.Latitude - currentPosition.Latitude) < 0.0001 &&
Math.Abs(_lastPosition.Longitude - currentPosition.Longitude) < 0.0001)
{
// Positions are nearly the same; ignore this update
return;
}
_lastPosition = currentPosition;
try
{
await BaseService.AddNewAttendanceLocationTracking(new AttendanceLocationTrackingModel()
{
AttendanceId = AttendanceId,
UserId = long.Parse(Settings.UserId),
Latitude = currentPosition.Latitude,
Longitude = currentPosition.Longitude,
});
}
catch (Exception ex)
{
// Handle exceptions
}
}
Hey, when I try to use this Crossgeolocator library with Android 13, the GPS Signal moves a lot, even though the device doesnt move. When I try it with Android 11 or so, it works just fine