我们已经为 Android 实现了基于地理的应用程序,因此我们需要确保始终启用 GPS。问题是
manager.isProviderEnabled( LocationManager.GPS_PROVIDER )
即使启用了 GPS 提供程序,它也始终返回 false,因此我们的应用程序始终显示更改 GPS 状态的警报或它不工作。
你知道发生了什么吗?
我们正在使用 Samsung Galaxy S 和 HTC Wildfire 设备对其进行测试... 提前致谢。
最佳答案
您可以直接从系统获取 GPS 状态:
LocationManager myLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
private boolean getGPSStatus()
{
String allowedLocationProviders =
Settings.System.getString(getContentResolver(),
Settings.System.LOCATION_PROVIDERS_ALLOWED);
if (allowedLocationProviders == null) {
allowedLocationProviders = "";
}
return allowedLocationProviders.contains(LocationManager.GPS_PROVIDER);
}
关于android - GPS 的 IsProviderEnabled 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11341771/