RESOLUTION_REQUIRED 即使用户的位置处于开启状态。是否可以?

Jua*_*ini 7 android location

SettingsClient在一个应用上使用谷歌。它工作正常,但有些用户无法使用 GPS,即使他们打开了定位并且他们已经授予了定位权限。据我了解,如果在其上Settings Client返回RESOLUTION_REQUIREDFailureListener,那是因为用户已禁用位置。

真的吗?或者是否有任何其他原因返回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();
                }
            });
Run Code Online (Sandbox Code Playgroud)

man*_*n21 3

我遇到了这个问题,并发现这个问题是由位置模式引起的,即使GPS打开,但如果位置模式仍然选择“仅GPS”,则会发生此异常,当我更改为另一种模式时,它工作正常。不幸的是,您无法以编程方式设置位置模式,但您可以将用户直接发送到设置屏幕,他可以在其中执行此操作,请按照此 anwser /sf/answers/1802158711/

GPS模式图片