RESOLUTION_REQUIRED即使用户的位置已开启。可能吗?

问题描述 投票:4回答:1

我在应用上使用Google的SettingsClient。它工作正常,但有些用户无法使用GPS,即使他们已打开位置并且他们已经授予了对位置权限的访问权限。根据我的理解,如果Settings Client在它的FailureListener上返回RESOLUTION_REQUIRED,那是因为用户已禁用位置。

真的吗?或者是否有任何其他原因返回RESOLUTION_REQUIRED?

返回RESOLUTION_REQUIRED时,状态栏上不会显示GPS图标,但它应该在那里!

这是我的代码:

    SettingsClient mSettingsClient =
            LocationServices.getSettingsClient(context);

    LocationRequest mLocationRequest = new LocationRequest();
    mLocationRequest.setInterval(UPDATE_INTERVAL_MS);
    mLocationRequest.setFastestInterval(FASTEST_INTERVAL_MS);
    mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

    LocationSettingsRequest.Builder builder = new 
    LocationSettingsRequest.Builder();
    builder.addLocationRequest(mLocationRequest);
    mLocationSettingsRequest = builder.build();

    mSettingsClient.checkLocationSettings(mLocationSettingsRequest)
            .addOnSuccessListener(new OnSuccessListener<LocationSettingsResponse>() {
                @Override
                public void onSuccess(LocationSettingsResponse locationSettingsResponse) {
                    connected = true;
                    // Fused Location code...
                }
            })
            .addOnFailureListener(new OnFailureListener() {
                @Override
                public void onFailure(@NonNull Exception e) {
                    connected = false;
                    gpsFailureMessage = e.getMessage();
                }
            });
android location
1个回答
1
投票

我正面临这个问题并找出这个问题导致的位置模式,即使GPS打开,但如果位置模式仍然选择“仅GPS”将发生此异常,当我更改为另一种模式,它工作正常。遗憾的是,您无法以编程方式设置位置模式,但您可以将用户直接发送到他可以执行此操作的设置屏幕,请按照此anwser https://stackoverflow.com/a/25745124/8921450

GPS mode picture

© www.soinside.com 2019 - 2024. All rights reserved.