我正在使用 Fused Location Provider 开发应用程序。我有个疑问。为了定期获取位置,它使用 requestLocationUpdates()。但它从哪个来源获取位置,无论是从 WIFI 还是 GPS 或网络。在我的应用程序中,只有当 WiFi 开启时,它才会定期获取位置。当 WiFi 处于关闭状态时,它无法获取位置(它应该从 GPS 或网络的其他来源获取位置。但它永远不会获取位置。或者我必须为 GPS 和网络编写侦听器)。我不知道是什么问题。谁能帮我。
而且,它是否仅在所有提供商(Wifi、GPS、网络)可用时才有效。
public void checkPlay(){
  int resp = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
    if (resp == ConnectionResult.SUCCESS) {
        locationClient = new LocationClient(this, this, this);
        locationClient.connect();
    } else {
        Toast.makeText(this, "Google Play Service Error " + resp,
                Toast.LENGTH_LONG).show();
    }
 }
public void onConnected(Bundle arg0) {
    // TODO Auto-generated method stub
    if (locationClient != null && locationClient.isConnected()) {
        locationRequest = LocationRequest.create();
        locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
        locationRequest.setInterval(100);
        locationClient.requestLocationUpdates(locationRequest, this);
    }
}
        public void onLocationChanged(Location location) {
    // TODO Auto-generated method stub
    try {
        if (location != null) {
            lat = location.getLatitude();
                            long = location.getLongitude();
        }
    } catch (Exception e) {
        Log.d(Fots.TAG,
                "GpsTrackService.mGpsLocationListener.onLocationChanged", e);
    }       
}