0
我已经完成了这个代码,我想获得经度和纬度,但同时使用网络提供商和GPS提供商我得到我的位置为空。即使GPS启用...为什么这样?Android网络提供商和GPS提供商返回空
boolean isGPSEnabled = lm.isProviderEnabled(LocationManager.GPS_PROVIDER); boolean isNetworkEnabled = lm .isProviderEnabled(LocationManager.NETWORK_PROVIDER); Location location = null; if (!isGPSEnabled && !isNetworkEnabled) { } else if(isGPSEnabled) { location = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER); if(location == null) { if(isNetworkEnabled) location = lm.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); if(location == null) { } } } else if(isNetworkEnabled){ location = lm.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); if(location == null) { } }
重复的问题 http://stackoverflow.com/questions/12597076/network-provider-and-gps-provider-returning-null-values?rq=1 – Tugrul
也有一些是在Android的新版本。 你使用的是设备还是仿真器。如果设备是什么版本。 –
它的索尼手机 – user3278732