public void RemoveLocationListener(ILocationListener listener) { if (listener != null) { // remove the listener and stop location updates if necessary locator.PositionChanged -= listener.LocationChanged; registeredListeners.Remove(listener); if (locator.IsListening && registeredListeners.Count == 0) { locator.StopListeningAsync(); } } }
public void Pause() { if (_crossGeolocator != null) { _crossGeolocator.StopListeningAsync(); } }
public async void Listen() { position = null; CurrentState = State.Unknown; if (locator.IsListening) { await locator.StopListeningAsync(); } if (!locator.IsGeolocationEnabled || !locator.IsGeolocationAvailable || !await locator.StartListeningAsync(TimeSpan.FromSeconds(10), 100)) { CurrentState = State.Error; } #if DEBUG // For emulators else { Position _position = await locator.GetLastKnownLocationAsync(); if (position == null && _position != null) { position = _position; CurrentState = State.Success; } } #endif }
protected override async void OnDisappearing() { base.OnDisappearing(); locator.PositionChanged -= Locator_PositionChanged; await locator.StopListeningAsync(); }
public async Task StopListening() { if (!locator.IsListening) { return; } await locator.StopListeningAsync(); }
private async void StopListeningAsync() { if (!geolocatorInstance.IsListening) { return; } await geolocatorInstance.StopListeningAsync(); geolocatorInstance.PositionChanged -= Current_PositionChanged; }
protected async Task CleanUp() { _lastUpdatedTime = DateTime.MinValue; _previousLocation = null; if (_positionChangeHandler != null) { _geoLocator.PositionChanged -= _positionChangeHandler; _positionChangeHandler = null; } if (_geoLocator.IsListening) { await _geoLocator.StopListeningAsync(); } }
public async void AddListener(EventHandler <PositionEventArgs> listener, bool includeHeading) { if (SensusServiceHelper.Get().ObtainPermission(Permission.Location) != PermissionStatus.Granted) { throw new Exception("Could not access GPS."); } // if we're already listening, stop listening first so that the locator can be configured with // the most recent listening settings below. if (ListeningForChanges) { await _locator.StopListeningAsync(); } // add new listener PositionChanged += listener; _listenerHeadings.Add(new Tuple <EventHandler <PositionEventArgs>, bool>(listener, includeHeading)); _locator.DesiredAccuracy = SensusServiceHelper.Get().GpsDesiredAccuracyMeters; await _locator.StartListeningAsync(TimeSpan.FromMilliseconds(SensusServiceHelper.Get().GpsMinTimeDelayMS), SensusServiceHelper.Get().GpsMinDistanceDelayMeters, _listenerHeadings.Any(t => t.Item2), GetListenerSettings()); SensusServiceHelper.Get().Logger.Log("GPS receiver is now listening for changes.", LoggingLevel.Normal, GetType()); }
public async Task StopTracking() { if (!_geolocator.IsListening) { return; } await _geolocator.StopListeningAsync(); _geolocator.PositionChanged -= PositionChanged; if (!Positions.Any() || Positions.Count < 2) { return; } _messagingHandler.SendMessage(Positions); }
public async Task StopAsync() { _geolocatorService.PositionChanged -= GeolocatorServiceOnPositionChanged; await _geolocatorService.StopListeningAsync(); }
public void Stop() { _geoLocator.StopListeningAsync(); _geoLocator.PositionChanged -= OnLocationUpdate; }
protected override void OnDisappearing() { locator.StopListeningAsync(); }
public Task <bool> StopListeningAsync() { return(bestGeolocator.StopListeningAsync()); }
public async void StopListening() { await locator.StopListeningAsync(); }
public Model.Position CurrentLocation() { if (_geolocator == null) { return(null); } if (!_geolocator.IsGeolocationAvailable) { return(null); } if (!_geolocator.IsGeolocationEnabled) { return(null); } if (!_geolocator.IsListening) { _geolocator.StartListeningAsync(1, 1); } if (!_geolocator.IsListening) { return(null); } if (!_geolocator.IsGeolocationAvailable) { try { var page = new ContentPage(); var r = page.DisplayAlert("Προσοχή", "Η συσκευή δεν διαθέτει GPS ή άλλη αντίστοιχη λειτουργία τοποθεσίας.", "OK"); } catch (Exception ex) { if (ex != null && !String.IsNullOrEmpty(ex.Message)) { Mvx.Error(ex.Message); } } return(null); } if (!_geolocator.IsGeolocationEnabled) { try { var page = new ContentPage(); var r = page.DisplayAlert("Προσοχή", string.Format("Η λειτουργία τοποθεσίας είναι απενεργοποιημένη.{0}Παρακαλώ ενεργοποιήστε την τοποθεσία και δοκιμάστε ξανά.", System.Environment.NewLine), "OK"); } catch (Exception ex) { if (ex != null && !String.IsNullOrEmpty(ex.Message)) { Mvx.Error(ex.Message); } } return(null); } Plugin.Geolocator.Abstractions.Position p = _geolocator.GetPositionAsync(5000).Result ?? null; if (!_geolocator.IsListening) { _geolocator.StopListeningAsync(); } //return p; return(new Model.Position() { Latitude = p.Latitude, Longitude = p.Longitude }); }
/// <summary> /// This method ends current activity. /// </summary> public async Task StopActivityAsync() { await _geolocatorService.StopListeningAsync(); CurrentActivity.Status = ActivityStatus.Stopped; }
private async void Stop(object sender, EventArgs eventArgs) { await geolocator.StopListeningAsync(); SetValues(); }
/// <summary> /// Stops the run. /// </summary> /// <returns>The run.</returns> public void StopRun() { IsRunning = false; m_locator.StopListeningAsync(); OnRunStoped(); }
private async void OnDisappearing(object sender, EventArgs e) { await geoLocator.StopListeningAsync(); }