How can I request “High Accuracy” Location with the new SettingsApi on GooglePlayServices?

浪子不回头ぞ 提交于 2019-12-13 07:04:57

问题


I'm trying to use the new SettingsApi (https://developer.android.com/reference/com/google/android/gms/location/SettingsApi.html) from GooglePlayServices to detect the need for changes on users settings without exiting the app.

My problem is that the dialog appears, but it only says it will require the Wifi and internet to access location. I also want it to request the GPS (this, is the High Accuracy mode or the device only mode).

My code for getting the LocationSettingsRequest:

public static LocationSettingsRequest getHighPriorityLocationSettingsRequest() {
        LocationRequest locationRequest = LocationRequest.create();
        locationRequest.setFastestInterval(FASTEST_INTERVAL);
        locationRequest.setInterval(UPDATE_INTERVAL_ACTIVE);
        locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

        return new LocationSettingsRequest.Builder()
                .addLocationRequest(locationRequest)
                .setAlwaysShow(true)
                .build();
    }

Thank you!


回答1:


The dialog only lists the changes needed to put your location settings to a more optimized states. Thus it won't ask you for GPS when:

  • GPS is not available on your device, or
  • GPS is already on.

By the way, neither FASTEST_INTERVAL nor UPDATE_INTERVAL_ACTIVE has any effect on that dialog.



来源:https://stackoverflow.com/questions/29755109/how-can-i-request-high-accuracy-location-with-the-new-settingsapi-on-googlepla

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!