如何检查Windows Phone 8中启用的位置服务?

时间:2014-05-28 05:22:43

标签: c# windows-phone-8

如何检查Windows Phone 8中是启用还是禁用位置服务?

2 个答案:

答案 0 :(得分:2)

  public bool IsLocationServiceEnabled
  {
   get
   {
     Geolocator locationservice = new Geolocator();
     if (locationservice.LocationStatus == PositionStatus.Disabled)
     {
      return false;
     }
     return true;
   }
  }

How to Find if the Location Services are Turned Off

答案 1 :(得分:2)

using Windows.Devices.Geolocation;

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

此外,PositionStatus枚举还有几个值,如:

Ready, NoData, Initializing, Disabled, NotInitialized, NotAvailable.

希望这会对你有所帮助。 谢谢和欢呼。