/// <inheritdoc /> public Task <GeolocationAccessStatus> RequestAccessAsync() { var status = this.locationProviders.Any(this.locationManager.IsProviderEnabled) ? GeolocationAccessStatus.Allowed : GeolocationAccessStatus.Denied; if (this.locationListener == null && status == GeolocationAccessStatus.Allowed) { this.locationListener = new GeolocatorLocationListener( this.locationManager, this.ReportInterval, this.locationProviders); this.locationListener.PositionChanged += this.LocationListener_PositionChanged; this.locationListener.StatusChanged += this.LocationListener_StatusChanged; var looperThread = Looper.MyLooper() ?? Looper.MainLooper; foreach (var provider in this.locationProviders) { this.locationManager.RequestLocationUpdates( provider, this.reportInterval, this.DesiredAccuracyInMeters, this.locationListener, looperThread); } } return(Task.FromResult(status)); }
private void LocationListener_PositionChanged(GeolocatorLocationListener sender, PositionChangedEventArgs args) { lock (this.obj) { this.LastKnownPosition = args.Position; this.PositionChanged?.Invoke(this, args); } }
private void LocationListener_StatusChanged(GeolocatorLocationListener sender, StatusChangedEventArgs args) { this.LocationStatus = args.Status; this.StatusChanged?.Invoke(this, args); }