Karumi / Dexter

Android library that simplifies the process of requesting permissions at runtime.
http://karumi.com
Apache License 2.0
5.23k stars 671 forks source link

report.isAnyPermissionPermanentlyDenied is always true #139

Closed cesarsicas closed 7 years ago

cesarsicas commented 7 years ago

Hi, im trying to achieve the following behaviour:

1 - Dexter checks for multiple permissions.

2 - When ther user click on Deny, a Dialog is showed on onPermissionRationaleShouldBeShown() method and token.continuePermissionRequest() is called. Then the activity is closed

3 - When the user click on Allow, my method startApplication() is called .

But the problem is, inside method onPermissionsChecked(), the value of report.isAnyPermissionPermanentlyDenied is always true, and the value of report.areAllPermissionsGranted is always false , regardless of which option the user checks.

How can i achieve this ?

Expected behaviour

Check if the user deny or allow multiple permissions

Actual behaviour

the value of report.isAnyPermissionPermanentlyDenied is always true, and the value of report.areAllPermissionsGranted is always false , regardless of which option the user checks.

Steps to reproduce


Dexter.withActivity(this)
                .withPermissions(
                        Manifest.permission.ACCESS_FINE_LOCATION,
                        Manifest.permission.READ_PHONE_STATE,
                        Manifest.permission.ACCESS_NETWORK_STATE,
                        Manifest.permission.ACCESS_COARSE_LOCATION,
                        Manifest.permission.WRITE_EXTERNAL_STORAGE,
                        Manifest.permission.READ_EXTERNAL_STORAGE,
                        Manifest.permission.MANAGE_DOCUMENTS,
                        Manifest.permission.CAMERA
                ).withListener(object : MultiplePermissionsListener {
            override fun onPermissionsChecked(report: MultiplePermissionsReport) {

                if(report.areAllPermissionsGranted()){ // <<<< always false
                    startApplication()
                }

            }

            override fun onPermissionRationaleShouldBeShown(permissions: List<PermissionRequest>, token: PermissionToken) {/* ... */
                DialogUtils.customErrorDialog(this@SplashscreenActivity,
                        "Essas permissões são necessárias para utilizar o Aplicativo"){ onClick ->
                            if(onClick){
                                token.continuePermissionRequest()
                                finish()
                            }
                        }

                    token.continuePermissionRequest()

            }

        }).check()

Version of the library

com.karumi:dexter:3.0.2

Serchinastico commented 7 years ago

Hi @JulioCesarSiqueira

Looks like the problem is with the MANAGE_DOCUMENTS permission. As stated in the Android documentation, this permission is not granted to 3rd party apps but only to the platform document management app. If you need this permission you probably have to include a workaround, this are two good references for the known issue: SO1, SO2.

Let us know if this is actually the problem so that we can close the issue.

Thanks again!

cesarsicas commented 7 years ago

@Serchinastico thank you very much!

I removed this permission and worked great.