简体   繁体   English

如果GPS已打开,则Android设置API会打开WiFi,以提高位置准确性

[英]Android Settings API turn on WiFi to improve location accuracy if GPS is already turned on

I have use new Settings API to turn on GPS without to leave my application. 我已经使用新的Settings API来打开GPS,而无需离开我的应用程序。 http://android-developers.blogspot.in/2015/03/google-play-services-70-places-everyone.html I have this locationRequest with PRIORITY_HIGH_ACCURACY to use GPS. http://android-developers.blogspot.in/2015/03/google-play-services-70-places-everyone.html我有这个locationRequest和PRIORITY_HIGH_ACCURACY来使用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);

but GMS Location not use GPS only it appears message to turn on WiFi too. 但GMS位置信息不使用GPS,它也会显示消息来打开WiFi。 I have try to remove forget all WiFi networks and message from GMS is changed and adding request from google to collect anonymous location data and send it.. How to skip this message if WiFi is off? 我已尝试删除忘记所有WiFi网络的信息,并更改了GMS中的消息,并添加了来自Google的请求以收集匿名位置数据并将其发送。如果WiFi关闭,如何跳过此消息?

From LocationRequest documentation: 从LocationRequest文档中:

The priority of the request is a strong hint to the LocationClient for which location sources to use. 请求的优先级是向LocationClient强烈提示使用的位置源。 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,PRIORITY_BALANCED_POWER_ACCURACY更有可能使用WIFI和基站定位,但是它还取决于许多其他因素(例如哪些来源可用),并且取决于实现方式。

PRIORITY_HIGH_ACCURACY is more likely to use GPS - if GPS is enable why its need to send user message to enable WiFi? PRIORITY_HIGH_ACCURACY更可能使用GPS-如果启用了GPS,为什么它需要发送用户消息来启用WiFi? and this not depend of the accuracy of the GPS coordinates. 这不取决于GPS坐标的精度。 Every time if GPS is enabled Settings API show dialog to enable WiFi. 每次启用GPS时,Settings API显示对话框以启用WiFi。

See LocationSettingsStates. 请参阅LocationSettingsStates。 isGpsUsable() . 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);
            }
        }
    }

PRIORITY_HIGH_ACCURACY表示您正尝试从设备GPS,Wifi和移动网络中获取位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM