googlesamples / easypermissions

Simplify Android M system permissions
https://firebaseopensource.com/projects/googlesamples/easypermissions/
Apache License 2.0
9.87k stars 1.46k forks source link

EasyPermissions.hasPermissions is not correct ,can you help me #255

Closed wohsj110 closed 6 years ago

wohsj110 commented 6 years ago

Basic Information

Device type: Red mi note4x OS version: 7.0 EasyPermissions version: 2.0.0

Describe the problem

why the result of EasyPermissions.hasPermissions not the same PermissionChecker.checkPermission()

What happened? What did you expect to happen? i use EasyPermissions to require Camera permissions bug Denied by the MIUI not the system in system setting show that ,i have the camera permissions however i use EasyPermissions.hasPermissions the result is wrong I use PermissionChecker.checkPermission() ,the result is right

Code and logs

 String permissionCamera = Manifest.permission.CAMERA;
        String permissionAudio = Manifest.permission.RECORD_AUDIO;

        if (PermissionChecker.checkSelfPermission(mContext, permissionCamera) != PackageManager.PERMISSION_GRANTED ||
                PermissionChecker.checkSelfPermission(mContext, permissionAudio) != PackageManager.PERMISSION_GRANTED) {
            if (!ActivityCompat.shouldShowRequestPermissionRationale((Activity) mContext, Manifest.permission.CAMERA)) {
                Toast.makeText(mContext, R.string.permission_tips, Toast.LENGTH_LONG).show();
            } else {
                String[] permissions = new String[]{Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO};
                ActivityCompat.requestPermissions((Activity) mContext, permissions, PERMISSION_CAMERA_CODE);
            }
        } else {
            startCameraActivity();
        }

------------------------------------ i am a line --------------------------------------

 if (EasyPermissions.somePermissionDenied(mActivity, CAMERA_AND_AUDIO_PERM)) {
            if (mActivity != null) {
                new AppSettingsDialog
                        .Builder(mActivity)
                        .setTitle(R.string.rationale_title)
                        .setNegativeButton(R.string.rationale_negative)
                        .setPositiveButton(R.string.rationale_positive)
                        .setRationale(R.string.rationale_camera_content)
                        .build()
                        .show();
            }
        } else {
            if (EasyPermissions.hasPermissions(mActivity, CAMERA_AND_AUDIO_PERM)) {
                startCameraActivity();
            } else {
                EasyPermissions.requestPermissions(mActivity, PERMISSION_CAMERA_CODE, CAMERA_AND_AUDIO_PERM);

            }
        }
samtstern commented 6 years ago

@martin-huang could you show the problem with a slightly simpler example? Also what happens if you use ContextCompat directly?

samtstern commented 6 years ago

No response for 28 days, so closing this issue as not reproducible.