Search code examples
windows-phone-8location

Windows Phone 8 Check if location is turned on/off?


I want to check if the location service is turned on or off, so I can inform the user that he needs to turn it on in order to see his location on the map. Also want to check if airplane mode is on/off and if WiFi is turned on/off. Any suggestions?


Solution

  • For location:

    Geolocator locator = new Geolocator();
    if (locator.LocationStatus == PositionStatus.Disabled)
    {
        // Location is turned off
    }
    

    For network stuff, see DeviceNetworkInformation class. E.g.

    bool isWifiOn = DeviceNetworkInformation.IsWiFiEnabled;
    

    See also: How to detect network changes for Windows Phone