Fusionlocationprovider 在 android 中没有 gps 时无法工作
Fusionlocationprovider not working without gps in android
我正在开发 google 地图应用程序,我正在使用 google 融合位置提供程序来查找当前位置,我正在尝试请求位置更新,但我在使用 gps 和位置请求优先级时遇到的问题HIGH_ACCURACY,我的电池消耗得非常快,这就是为什么我想将我的位置请求优先级更改为 BALANCED_POWER 但没有 gps 我无法获得纬度和经度但是在 google 文档中他们提到没有gps 应该也可以,请回复
代码:
_googleApiClient = new GoogleApiClient.Builder(this)
.addApi(LocationServices.API)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
_locationRequest = new LocationRequest();
_locationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
PendingResult<Status> pendingResult = LocationServices.FusedLocationApi.requestLocationUpdates(
_googleApiClient, _locationRequest,this);
PRIORITY_BALANCED_POWER_ACCURACY 根据 google 文档仅获取基于网络的位置。它只需要 ACCESS_COARSE_LOCATION 这意味着它只根据网络而不是 GPS 获取位置。看看this post。
如果您想使用 GPS,您应该前往 HIGH_ACCURACY 个位置。作为您对地图的要求,这样做是有意义的。您不应该忘记在不需要时删除位置更新。在你的情况下,我想你应该在你的 activity 进入后台时停止......可能在 onStop() 或 onPause() 中。阅读 Location Strategies 了解更多信息。
我正在开发 google 地图应用程序,我正在使用 google 融合位置提供程序来查找当前位置,我正在尝试请求位置更新,但我在使用 gps 和位置请求优先级时遇到的问题HIGH_ACCURACY,我的电池消耗得非常快,这就是为什么我想将我的位置请求优先级更改为 BALANCED_POWER 但没有 gps 我无法获得纬度和经度但是在 google 文档中他们提到没有gps 应该也可以,请回复
代码:
_googleApiClient = new GoogleApiClient.Builder(this)
.addApi(LocationServices.API)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
_locationRequest = new LocationRequest();
_locationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
PendingResult<Status> pendingResult = LocationServices.FusedLocationApi.requestLocationUpdates(
_googleApiClient, _locationRequest,this);
PRIORITY_BALANCED_POWER_ACCURACY 根据 google 文档仅获取基于网络的位置。它只需要 ACCESS_COARSE_LOCATION 这意味着它只根据网络而不是 GPS 获取位置。看看this post。
如果您想使用 GPS,您应该前往 HIGH_ACCURACY 个位置。作为您对地图的要求,这样做是有意义的。您不应该忘记在不需要时删除位置更新。在你的情况下,我想你应该在你的 activity 进入后台时停止......可能在 onStop() 或 onPause() 中。阅读 Location Strategies 了解更多信息。