How can i get gps coordinates

How can i get gps coordinates

BY 22 Oct 2019 Tizen .NET

Hi! How can i get coordinates from gps or hybrid location? The sample doesn’t work anymore. https://github.com/Samsung/Tizen-CSharp-Samples/tree/master/Wearable/Location In my code, the event isn’t triggered.

 

 private async void FetchGpsLocation()
        {
            if (this.locator == null)
            {
                try
                {
                    
                    this.locator = new Locator(LocationType.Hybrid);

                    // Create GpsSatellite instance
                    this.satellite = new GpsSatellite(locator);

                    if (locator != null)
                    {
                        // Starts the Locator which has been created using the specified method.
                        locator.Start();

                        // Add ServiceStateChanged event to receive the event regarding service state
                        locator.ServiceStateChanged += LocatorServiceStateChanged;
                    }
                }
                catch (Exception ex)
                {
                    // Exception handling
                }
            }
        }

        public async void LocatorServiceStateChanged(object sender, ServiceStateChangedEventArgs e)
        {
            if (e.ServiceState == ServiceState.Enabled)
            {
                // Service is enabled

                this.gpsNotFound_.IsVisible = false;
                this.gpsFound_.IsVisible = true;
                double x = this.locator.GetLocation().Longitude;
                double y = this.locator.GetLocation().Altitude;
                List list = await Task.Run(async () => await setTitleGpsAsBusSTop(x, y));
                this.gpsFound_.IsVisible = false;
                this.stopFound_.IsVisible = true;
                this.stop_name_gps_.Text = list[0].stop_name;
                this.stop_dist_gps_.Text = list[0].dist;                
                var list1 = await Task.Run(async () => await setNearestBusStopTimes(list[0].stop_name, list[0].dist, list[0].stop_id));
                clvg.ItemsSource = list1;
                this.loading_Gps.IsRunning = false;
            }
            else
            {
                // Service is disabled
                this.stop_name_gps_.Text = "Gps disattivato";
                this.LoadingGps.IsRunning = false;
            }
        }

 

Written by