コード例 #1
0
        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);
            }
        }
コード例 #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;
        }
コード例 #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;
      }
コード例 #4
0
      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 );
         }
      }