Exemple #1
0
        static Task DoStartTracking(LocationTrackingSettings settings)
        {
            Listener = new GeoLocationContinuousListener(Manager, settings.ReportInterval, Providers);
            Listener.PositionChanged.Handle(x => OnListenerPositionChanged(x));
            Listener.PositionError.Handle(OnListenerPositionError);

            var looper = Looper.MyLooper() ?? Looper.MainLooper;

            for (var i = 0; i < Providers.Length; ++i)
            {
                Manager.RequestLocationUpdates(Providers[i], (long)settings.ReportInterval.TotalMilliseconds, settings.MovementThreshold, Listener, looper);
            }

            return(Task.CompletedTask);
        }
Exemple #2
0
        public static Task <bool> StopTracking()
        {
            if (Listener == null)
            {
                return(Task.FromResult(result: true));
            }

            Listener.PositionChanged.RemoveHandler(OnListenerPositionChanged);
            Listener.PositionError.RemoveHandler(OnListenerPositionError);

            for (int i = 0; i < Providers.Length; ++i)
            {
                Manager.RemoveUpdates(Listener);
            }

            Listener = null;
            return(Task.FromResult(result: true));
        }