コード例 #1
0
        public async void AsyncGetUserCurrentLocations(LocationUpdatedEventArgs e)
        {
            NetworkStatus remoteHostStatus = Reachability.RemoteHostStatus();

            if (remoteHostStatus == NetworkStatus.NotReachable)
            {
                var alert = UIAlertController.Create("Network Error", "Please check your internet connection", UIAlertControllerStyle.Alert);
                alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, null));
                PresentViewController(alert, animated: true, completionHandler: null);

                return;
            }

            CLLocation location = e.Location;

            ServiceManager jobService      = new ServiceManager();
            string         currentLocation = await jobService.AsyncGetUserCurrentLocations(location.Coordinate.Latitude.ToString(), location.Coordinate.Longitude.ToString());

            Console.WriteLine("location :=  " + currentLocation);

            if (string.IsNullOrEmpty(currentLocation))
            {
                BTProgressHUD.ShowToast("Unable to track location.Please try later...", false, 3000);
            }
            else
            {
                txtLocation.Text = currentLocation;
            }
        }
コード例 #2
0
        //This will keep going in the background and the foreground
        public void PrintLocation(object sender, LocationUpdatedEventArgs e)
        {
            CLLocation location = e.Location;

            Console.WriteLine("Altitude: " + location.Altitude + " meters");
            Console.WriteLine("Longitude: " + location.Coordinate.Longitude);
            Console.WriteLine("Latitude: " + location.Coordinate.Latitude);
            Console.WriteLine("Course: " + location.Course);
            Console.WriteLine("Speed: " + location.Speed);

            //this.locationManager.StopUpdatingLocation();
            // stop location updates until timer calls StartUpdatingLocation
        }
コード例 #3
0
        public void HandleLocationChanged(object sender, LocationUpdatedEventArgs e)
        {
            // Handle foreground updates
            Console.WriteLine("foreground updated");


            CLLocation location = e.Location;



            if (!_searchingLocation)
            {
                _searchingLocation = true;
                AsyncGetUserCurrentLocations(e);
            }

            Manager.StopLocationUpdates();
            //Manager = null;
        }