Gps 检测Windows 8设备上是否有可用的传感器

Gps 检测Windows 8设备上是否有可用的传感器,gps,windows-8,windows-runtime,sensors,Gps,Windows 8,Windows Runtime,Sensors,如何检测Windows 8设备上是否有传感器?我的应用程序需要GPS才能正常工作,因此我需要一种方法来检测它在运行的设备上是否可用。您可以检查Geolocator对象的LocationStatus属性。。。如果它不可用或被禁用,您就倒霉了…您可以检查Geolocator对象的LocationStatus属性。。。如果它不可用或被禁用,你就倒霉了…这里有一些适用于Windows 8设备的传感器 您可以通过GetDefault()方法检查它们是否可用。如果传感器不可用,则返回“null” if(Ac

如何检测Windows 8设备上是否有传感器?我的应用程序需要GPS才能正常工作,因此我需要一种方法来检测它在运行的设备上是否可用。

您可以检查Geolocator对象的LocationStatus属性。。。如果它不可用或被禁用,您就倒霉了…

您可以检查Geolocator对象的LocationStatus属性。。。如果它不可用或被禁用,你就倒霉了…

这里有一些适用于Windows 8设备的传感器

您可以通过GetDefault()方法检查它们是否可用。如果传感器不可用,则返回“null”

if(Accelerometer.GetDefault() != null)
{
    // your code
}
if (Compass.GetDefault() != null)
{
    // your code
}
if (Gyrometer.GetDefault() != null)
{
    // your code
}

以下是一些适用于Windows 8设备的传感器

您可以通过GetDefault()方法检查它们是否可用。如果传感器不可用,则返回“null”

if(Accelerometer.GetDefault() != null)
{
    // your code
}
if (Compass.GetDefault() != null)
{
    // your code
}
if (Gyrometer.GetDefault() != null)
{
    // your code
}

我试过了。我的笔记本电脑没有GPS;)但状态显示为
NoData
,而不是
Disabled
NotAvailable
。由于即使GPS传感器存在,
NoData
也可能是状态,这会造成问题。我已经尝试过了。我的笔记本电脑没有GPS;)但状态显示为
NoData
,而不是
Disabled
NotAvailable
。由于即使存在GPS传感器,
NoData
也可能是状态,因此会产生问题。