예제 #1
0
        async private void ButtonFinishClicked(object sender, EventArgs e)
        {
            if ((CrossConnectivity.Current.IsConnected == false))
            {
                await DisplayAlert(Constants.internetAlertTittle, Constants.internetAlertMessage, null, Constants.internetButton);
            }
            else
            {
                bool answer = await DisplayAlert("", string.Format("Are you sure you want to end the walk?"), "Cancel", "OK");

                if (!answer)
                {
                    await locator.StopListeningAsync();

                    isListening            = false;
                    poopButton.IsEnabled   = false;
                    poopButton.Image       = "dogPoopUnable";
                    peeButton.IsEnabled    = false;
                    peeButton.Image        = "dogPeeUnable";
                    FinishButton.IsEnabled = false;
                    AddFinishFlag();
                    AddDistanceToDogTatalWalk();
                    UpdateMyTrips();
                }
            }
        }
예제 #2
0
        void CheckLocationStatus(Object state)
        {
            TimerState s = (TimerState)state;

            //s.counter++;
            if (locator.IsGeolocationEnabled && locator.IsGeolocationAvailable)
            {
                // it's OK now, can stop timer
                s.tmr.Dispose();
                s.tmr = null;
                //TimeSpan gpsFreq = new TimeSpan(2 * TimeSpan.TicksPerMinute);
                locator.StopListeningAsync();
                // locator.StartListeningAsync(gpsFreq, 0);
                locator.StartListeningAsync(120000, 0);

                locator.PositionChanged += Locator_PositionChanged;
                locator.PositionError   += Locator_PositionError;
            }
            else
            {
                // warn user again
                //_player.Start();
                builder.SetContentTitle("GPS error:");
                builder.SetContentText("Trying to restart: " + DateTime.Now.ToShortTimeString());
                notification        = builder.Build();
                notificationManager = GetSystemService(Context.NotificationService) as NotificationManager;
                notificationID      = (int)NotificationFlags.ForegroundService;
            }
        }
예제 #3
0
        private void SetUpEventWidget()
        {
            TrackingButton.Text = "Start Location";

            TrackingButton.Clicked += async(sender, events) =>
            {
                if (TrackingButton.Text == "Start Location")
                {
                    // tracking

                    Geolocator = CrossGeolocator.Current;
                    Geolocator.DesiredAccuracy  = 100;
                    Geolocator.PositionChanged += (_sender, _event) =>
                    {
                        Console.WriteLine($"Position Status: {_event.Position.Timestamp}");
                        Console.WriteLine($"Position Latitude: {_event.Position.Latitude}");
                        Console.WriteLine($"Position Longitude: {_event.Position.Longitude}");

                        var currentLocation = new Position(_event.Position.Latitude, _event.Position.Longitude);
                        map.MoveToRegion(MapSpan.FromCenterAndRadius(currentLocation, Distance.FromMeters(200)));
                    };
                    await Geolocator.StartListeningAsync(TimeSpan.FromSeconds(5), 50);

                    Device.BeginInvokeOnMainThread(() => {
                        TrackingButton.Text = "Stop Location";
                    });
                }
                else
                {
                    bool result = await DisplayAlert("title", "message", "yes", "no");

                    if (result == true)
                    {
                        await Geolocator.StopListeningAsync();

                        Device.BeginInvokeOnMainThread(() => {
                            TrackingButton.Text = "Start Location";
                        });
                    }
                }
            };
        }
예제 #4
0
파일: MapPage.xaml.cs 프로젝트: cmhg/Travel
 protected async override void OnDisappearing()
 {
     base.OnDisappearing();
     await locator.StopListeningAsync();
 }