locked
[UWP]Slow location retrieval on Mobile device. RRS feed

  • Question

  • using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using Windows.Devices.Geolocation;
    
    namespace App_Code
    {
        public class locationManager
        {
            public static async Task<Geoposition> getLocationAuto()
            {
    
                var accessStatus = await Geolocator.RequestAccessAsync();
    
    
                if (accessStatus == GeolocationAccessStatus.Unspecified)
                {
                    var dialog = new Windows.UI.Popups.MessageDialog("There Seems to be some problem in your Device GPS");
                    await dialog.ShowAsync();
                    return null;
                }
                else if (accessStatus == GeolocationAccessStatus.Denied)
                {
                    var dialog = new Windows.UI.Popups.MessageDialog("Access to Location Services was Denied" + System.Environment.NewLine
                        + "settings-->privacy-->location");
                    await dialog.ShowAsync();
                    return null;
                }
    
                var geoLocator = new Geolocator { DesiredAccuracyInMeters = 0 };
    
                var position = await geoLocator.GetGeopositionAsync();
    
                
    
                return position;
    
            }
    
            
        }
    }

    Takes a long time to complete on Lumia 640.Though eventually I get my device location. I am on the release build 10586.164
     ! The same code returns location almost instantly on PC
    • Edited by Rahul Jha Sunday, April 3, 2016 8:53 AM
    • Edited by Barry Wang Monday, April 4, 2016 8:56 AM title tags
    Sunday, April 3, 2016 8:52 AM

Answers

  • If you increase the DesiredAccuracyInMeters to a larger amount it wont take as long to get the results.  
    • Marked as answer by Rahul Jha Sunday, April 3, 2016 7:52 PM
    Sunday, April 3, 2016 12:42 PM

All replies

  • If you increase the DesiredAccuracyInMeters to a larger amount it wont take as long to get the results.  
    • Marked as answer by Rahul Jha Sunday, April 3, 2016 7:52 PM
    Sunday, April 3, 2016 12:42 PM
  • And I thought setting it to zero meant least level of accuracy
    Sunday, April 3, 2016 7:53 PM