我正在使用Fused Location Provider开发一个应用程序。我有一个疑问:为了在规律的时间间隔内获取位置,它使用requestLocationUpdates()。但是,它从哪个来源获取位置信息,是通过WIFI、GPS还是网络?在我的应用程序中,只有当WiFi打开时才能按规律获取位置。当WiFi处于关闭状态时,它无法获取位置(它应该从其他来源(GPS或网络)获取位置,但却无法获取位置。或者我需要为GPS和网络编写监听器)。我不知道问题出在哪里。有人能帮帮我吗?
另外,它是否仅在所有提供程序(Wifi、GPS、Network)都可用时才起作用?
另外,它是否仅在所有提供程序(Wifi、GPS、Network)都可用时才起作用?
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);
}
}