Search code examples
c#uwpwindows-10-mobile

Can I do enable GPS programmatically from my app?


Windows 10 phone application. Can I do it programmatically or not? Windows 7 have no variants, maybe windows 10 mobile have new methods or variants?


Solution

  • Yes. But not if the user has disabled GPS on their device.

    First you need to enable it.

    From msdn site:

    1. In Solution Explorer, double-click package.appxmanifest and select the Capabilities tab.
    2. In the Capabilities list, select the Capabilities tab. This adds the Location device capability to the package manifest file.

    Then you can request access to the location. Example from msdn: Add this using statement:

    using Windows.Devices.Geolocation;

    And call this method:

    var accessStatus = await Geolocator.RequestAccessAsync();

    Read the documentation here for further details: https://msdn.microsoft.com/windows/uwp/maps-and-location/get-location