Android 设置 API 如果 GPS 已打开,则打开 WiFi 以提高定位精度
Android Settings API turn on WiFi to improve location accuracy if GPS is already turned on
我已经使用新设置 API 在不离开我的应用程序的情况下打开 GPS。
http://android-developers.blogspot.in/2015/03/google-play-services-70-places-everyone.html
我有这个带有 PRIORITY_HIGH_ACCURACY 的 locationRequest 来使用 GPS。
final LocationRequest locationRequest = LocationRequest.create()
.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY)
.setInterval(DriverApplication.TRACE_MAX_INTERVAL)
.setMaxWaitTime(DriverApplication.TRACE_MAX_INTERVAL*2)
.setFastestInterval(DriverApplication.TRACE_FASTEST_INTERVAL);
但 GMS 定位不使用 GPS,它也出现了打开 WiFi 的消息。我已尝试删除忘记所有 WiFi 网络和来自 GMS 的消息已更改并添加来自 google 的请求以收集匿名位置数据并发送它..
如果 WiFi 关闭,如何跳过此消息?
来自 LocationRequest 文档:
The priority of the request is a strong hint to the LocationClient for
which location sources to use. For example, PRIORITY_HIGH_ACCURACY is
more likely to use GPS, and PRIORITY_BALANCED_POWER_ACCURACY is more
likely to use WIFI & Cell tower positioning, but it also depends on
many other factors (such as which sources are available) and is
implementation dependent.
PRIORITY_HIGH_ACCURACY 更有可能使用 GPS - 如果启用了 GPS 为什么需要发送用户消息来启用 WiFi?这与 GPS 坐标的准确性无关。每次启用 GPS 时,设置 API 都会显示启用 WiFi 的对话框。
PRIORITY_HIGH_ACCURACY 表示您正在尝试从设备 GPS、Wifi 和移动网络获取位置。
查看 LocationSettingsStates。isGpsUsable()。
LocationSettingsStates locationSettingsStates = locationSettingsResult.getLocationSettingsStates();
if (!locationSettingsStates.isGpsPresent() || !locationSettingsStates.isGpsUsable()) {
Status status = locationSettingsResult.getStatus();
if (status.getStatusCode() == LocationSettingsStatusCodes.RESOLUTION_REQUIRED) {
try {
status.startResolutionForResult(StilActivity.this, REQUEST_CHECK_SETTINGS);
}
catch (IntentSender.SendIntentException th) {
Log.e(TAG, "Error opening settings activity.", th);
}
}
}
我已经使用新设置 API 在不离开我的应用程序的情况下打开 GPS。 http://android-developers.blogspot.in/2015/03/google-play-services-70-places-everyone.html 我有这个带有 PRIORITY_HIGH_ACCURACY 的 locationRequest 来使用 GPS。
final LocationRequest locationRequest = LocationRequest.create()
.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY)
.setInterval(DriverApplication.TRACE_MAX_INTERVAL)
.setMaxWaitTime(DriverApplication.TRACE_MAX_INTERVAL*2)
.setFastestInterval(DriverApplication.TRACE_FASTEST_INTERVAL);
但 GMS 定位不使用 GPS,它也出现了打开 WiFi 的消息。我已尝试删除忘记所有 WiFi 网络和来自 GMS 的消息已更改并添加来自 google 的请求以收集匿名位置数据并发送它.. 如果 WiFi 关闭,如何跳过此消息?
来自 LocationRequest 文档:
The priority of the request is a strong hint to the LocationClient for which location sources to use. For example, PRIORITY_HIGH_ACCURACY is more likely to use GPS, and PRIORITY_BALANCED_POWER_ACCURACY is more likely to use WIFI & Cell tower positioning, but it also depends on many other factors (such as which sources are available) and is implementation dependent.
PRIORITY_HIGH_ACCURACY 更有可能使用 GPS - 如果启用了 GPS 为什么需要发送用户消息来启用 WiFi?这与 GPS 坐标的准确性无关。每次启用 GPS 时,设置 API 都会显示启用 WiFi 的对话框。
PRIORITY_HIGH_ACCURACY 表示您正在尝试从设备 GPS、Wifi 和移动网络获取位置。
查看 LocationSettingsStates。isGpsUsable()。
LocationSettingsStates locationSettingsStates = locationSettingsResult.getLocationSettingsStates();
if (!locationSettingsStates.isGpsPresent() || !locationSettingsStates.isGpsUsable()) {
Status status = locationSettingsResult.getStatus();
if (status.getStatusCode() == LocationSettingsStatusCodes.RESOLUTION_REQUIRED) {
try {
status.startResolutionForResult(StilActivity.this, REQUEST_CHECK_SETTINGS);
}
catch (IntentSender.SendIntentException th) {
Log.e(TAG, "Error opening settings activity.", th);
}
}
}