Ejemplo n.º 1
0
        partial void btnStopLocationUpInside(UIButton sender)
        {
            if (CoreLocation.CLLocationManager.LocationServicesEnabled)
            {
                locationManager.StopUpdatingLocation();
            }

            if (CoreLocation.CLLocationManager.HeadingAvailable)
            {
                locationManager.StopUpdatingHeading();
            }
        }
Ejemplo n.º 2
0
        public void Stop()
        {
            //if (CoreLocation.CLLocationManager.LocationServicesEnabled)
            //{
            //    locationManager.StopUpdatingLocation();
            //}

            //if (CoreLocation.CLLocationManager.HeadingAvailable)
            //{
            //    locationManager.StopUpdatingHeading();
            //}

            mLocationManager.StopUpdatingLocation();
            mLocationManager.StopUpdatingHeading();
        }
Ejemplo n.º 3
0
        void tryCheckingNow()
        {
            if (CLLocationManager.LocationServicesEnabled == false)
            {
                Location = null; // location is not known
                LocationServicesStatus = LocationServicesStatusEnum.NotAuthorized;
                FailureInfo            = "Not authorized to use location services (2)";
                fireEvents();
                return;
            }

            DateTime timeStarted = DateTime.Now;

            Task.Run(async() =>
            {
                for (; ;)
                {
                    await Task.Delay(100);

                    if (TimeUpdated != null && TimeUpdated.Value >= timeStarted)
                    {
                        // stop listening
                        // note: events had already been fired
                        locationManager.StopUpdatingLocation();
                        return;
                    }

                    if (TimeUpdated != null && (DateTime.Now - TimeUpdated.Value).TotalMinutes < 5 && Location != null)
                    {
                        // location already known. no need to wait.
                        fireEvents();
                        return;
                    }

                    if ((DateTime.Now - timeStarted).TotalSeconds > 5)
                    {
                        FailureInfo = "Timeout";
                        fireEvents();
                        return;
                    }
                }
            });

            // start listening
            locationManager.StartUpdatingLocation();
        }