[Blankj/AndroidUtilCode]权限方法的问题

2024-07-15 756 views
9
描述 Bug

简洁地描述下 Bug。

  • AndroidUtilCode 的版本:utilcode 1.27.0
  • 出现 Bug 的设备型号:一加6T
  • 设备的 Android 版本:API28
相关代码
    PermissionUtils.permission(PermissionContant.ALLPermission).callback(new PermissionUtils.SimpleCallback() {

                @Override
                public void onGranted() {
                    new Handler().postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            initSplash();

                        }
                    }, ANIMATION_DURATION);
                }

                @Override
                public void onDenied() {
                    initSplash();
                }
            }).request();
  //判断是否开启定位权限
        PermissionUtils.permission(PermissionContant.LocationPERMISSON).callback(new PermissionUtils.SimpleCallback() {

            @Override
            public void onGranted() {
                AMapUtil.initLocation(TakePicCheckInActivity.this, new AMapUtil.LocationListener() {
                    @Override
                    public void getLocation(AMapLocation aMapLocation) {
                        LogUtils.d("签到页定位刷新");
                        currentLatLng = new LatLng(aMapLocation.getLatitude(), aMapLocation.getLongitude());
                        outter:
                        for (CompanySignPointDto pointBean : checkInPointList) {
                            float distance = AMapUtils.calculateLineDistance(currentLatLng, new LatLng(Double.valueOf(pointBean.getLatitude()), Double.valueOf(pointBean.getLongitude())));
                            // 两点距离大于半径才显示
                            noGps(NO_LOCATION);
                            if (distance < pointBean.getRadius()) {
                                //物料校验
                                if (null != wayBillDetailBean && null != pointBean && null != pointBean.getMaterialCodeList() && (pointBean.getMaterialCodeList().contains(wayBillDetailBean.getMaterialCode()) || pointBean.getMaterialCodeList().get(0).equals("ALL"))) {
                                    noGps(IN_LOCATION);
                                } else {
                                    noGps(NO_LOCATION);
                                }

                                break outter;
                            }

                        }
                    }

                    @Override
                    public void failureGetLoaction(int errorCode) {
                        noGps(IN_LOCATION);
                    }
                });
            }

            @Override
            public void onDenied() {
                noGps(NO_GPS_PREMISSION);

            }
        }).request();
异常堆栈
  1. 初始化获取权限的时候,直接就执行initSplash()的方法,没有延时
  2. 定位权限获取不到

回答

0

什么意思?权限获取不到?

7

已经完全授权了,但是定位的时候,还是执行了拒绝的方法

8

PermissionContant.ALLPermission,PermissionContant.LocationPERMISSON 我不知道是什么,高版本是权限组,你这样传我不知道是否可以

9

//日历权限组。 public static final String[] CALENDARPermission = {Manifest.permission.WRITE_CALENDAR}; //相机权限组, public static final String[] CAMERAPermission = {Manifest.permission.CAMERA}; //联系人权限组, public static final String[] CONTACTSPermission = {Manifest.permission.WRITE_CONTACTS}; //位置权限组, public static final String[] LOCATIONPermission = {Manifest.permission_group.LOCATION,Manifest.permission.ACCESS_FINE_LOCATION};

//电话权限组,
public static final String[] PHONEPermission = {Manifest.permission.READ_PHONE_STATE};
//传感器权限组。
public static final String[] SENSORSPermission = {Manifest.permission.BODY_SENSORS};
//短信权限组。
public static final String[] SMSPermission = {Manifest.permission.READ_SMS};
//存储权限组,
public static final String[] STORAGEPermission = {Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE};
//所有的权限
public static final String[] ALLPermission = {Manifest.permission_group.LOCATION,Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_PHONE_STATE,Manifest.permission.READ_CONTACTS,Manifest.permission.CALL_PHONE};
//打电话
public static final String[] CALLPHONEPERMISSON = {Manifest.permission.CALL_PHONE};
5

这是我的权限

3

为啥不用我提供的 PermissionConstants?试试看?

2

定位的权限是 permission.ACCESS_FINE_LOCATION, permission.ACCESS_COARSE_LOCATION

2

好的,我试试 3Q

4

解决了吗

9

OK了,我定位权限的问题