Tag: location provider

如何在Android中使用Wifi获取位置?

我希望通过Wifi获取位置并在谷歌地图中工作,这对我不起作用,但Gps是好的而不是问题。 我的代码: locationManager = (LocationManager) getSystemService(LOCATION_SERVICE); if (locationManager != null) { boolean gpsIsEnabled = locationManager .isProviderEnabled(LocationManager.GPS_PROVIDER); boolean networkIsEnabled = locationManager .isProviderEnabled(LocationManager.NETWORK_PROVIDER); if (gpsIsEnabled) { locationManager.requestLocationUpdates( LocationManager.GPS_PROVIDER, 5000L, 10F, (android.location.LocationListener) this); } else if (networkIsEnabled) { locationManager.requestLocationUpdates( LocationManager.NETWORK_PROVIDER, 5000L, 10F, (android.location.LocationListener) this); } else { // Show an error dialog that GPS is disabled… } } […]