Example #1
0
        public void StartListening(uint 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);
            }
        }
Example #2
0
        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;
        }
Example #3
0
		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;
		}
Example #4
0
		public void StartListening(uint 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);
		}