public void StartListening(int minTime, double minDistance, bool includeHeading) { if (minTime < 0) { throw new ArgumentOutOfRangeException("minTime"); } if (minDistance < 0) { throw new ArgumentOutOfRangeException("minDistance"); } if (IsListening) { throw new InvalidOperationException("This Geolocator is already listening"); } listener = new GeolocationContinuousListener(manager, TimeSpan.FromMilliseconds(minTime), providers); listener.PositionChanged += OnListenerPositionChanged; listener.PositionError += OnListenerPositionError; Looper looper = Looper.MyLooper() ?? Looper.MainLooper; for (int i = 0; i < providers.Length; ++i) { manager.RequestLocationUpdates(providers[i], minTime, (float)minDistance, listener, looper); } }
public void StopListening() { if (listener == null) { return; } listener.PositionChanged -= OnListenerPositionChanged; listener.PositionError -= OnListenerPositionError; for (int i = 0; i < providers.Length; ++i) { manager.RemoveUpdates(listener); } listener = null; }
public void StopListening() { if(listener == null) { return; } listener.PositionChanged -= OnListenerPositionChanged; listener.PositionError -= OnListenerPositionError; for(int i = 0; i < providers.Length; ++i) { manager.RemoveUpdates( listener ); } listener = null; }
public void StartListening( int minTime, double minDistance, bool includeHeading ) { if(minTime < 0) { throw new ArgumentOutOfRangeException( "minTime" ); } if(minDistance < 0) { throw new ArgumentOutOfRangeException( "minDistance" ); } if(IsListening) { throw new InvalidOperationException( "This Geolocator is already listening" ); } listener = new GeolocationContinuousListener( manager, TimeSpan.FromMilliseconds( minTime ), providers ); listener.PositionChanged += OnListenerPositionChanged; listener.PositionError += OnListenerPositionError; Looper looper = Looper.MyLooper() ?? Looper.MainLooper; for(int i = 0; i < providers.Length; ++i) { manager.RequestLocationUpdates( providers[i], minTime, (float)minDistance, listener, looper ); } }