Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Geolocation 无法获取Nexus 4和10上的准确地理位置_Geolocation_Gps_Wifi_Geocoding_Locationmanager - Fatal编程技术网

Geolocation 无法获取Nexus 4和10上的准确地理位置

Geolocation 无法获取Nexus 4和10上的准确地理位置,geolocation,gps,wifi,geocoding,locationmanager,Geolocation,Gps,Wifi,Geocoding,Locationmanager,如何在android设备上获得最准确的地理位置,我尝试了以下代码片段,但在Nexus 4和10上,即使打开gps,它也无法工作: LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); String locationProvider = locationManager.getBestProvider(new Criteri

如何在android设备上获得最准确的地理位置,我尝试了以下代码片段,但在Nexus 4和10上,即使打开gps,它也无法工作:

LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
            String locationProvider = locationManager.getBestProvider(new Criteria(), true);
            if (locationProvider != null) {
                //Log.d(TAG, "locationProvider is not null");
                Location lastKnownLocation = locationManager.getLastKnownLocation(locationProvider);

                if (lastKnownLocation != null) {
                    AppConstants.lat = latLon[0] = lastKnownLocation.getLatitude();
                    AppConstants.lon = latLon[1] = lastKnownLocation.getLongitude();
                    retryGenerating = false;
                    //Log.d(TAG, "lastKnownLocation, lat = " + AppConstants.lat + ", lon = " + AppConstants.lon);

                }
}

通过将
LocationProvider
显式设置为GPS提供程序,可以获得最精确的位置。预计精度通常为3-6米,在城市峡谷中可达30米。

您需要在室外自由观看天空。

外出后,第一个有效位置预计会延迟20-40秒。

这是什么意思,它不起作用?