GPS location – get only once?

GPS location – get only once?

BY 16 Apr 2021 General Support

Hello, I need create a function that show me currenct GPS location every 1 minute and I dont want start GPS module non-stop according to battery consumption, so I have timer and every 1 minute call this function. Problem is, that when I open my app.. waiting 1 minute to get location … succesfully get location… I move quite far… waiting … and not getting any update… I still see the same location.

public void getLocation()
        {
            try
            {
                latitude.Text = "updating...";
                longitude.Text = "updating...";

                locator = new Locator(LocationType.Hybrid);
                locator.Start();
                locator.Interval = 10;
                Tizen.Location.Location location = locator.GetLocation();

                if (location != null)
                {

                    latitude.Text = location.Latitude.ToString();
                    longitude.Text = location.Longitude.ToString();

                }
                else
                {
                    latitude.Text = "no GPS";
                }

                locator.Stop();
                locator.Dispose();
                locator = null;
                location = null;
            }
            catch (Exception ex)
            {
                gps.Text = "no GPS";
            }
        }

      

Written by