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

Didn't get right result when set targetSdkVersion to 15 #140

Open johnwatsondev opened 7 years ago

johnwatsondev commented 7 years ago

Expected behaviour

Testing Device: Nexus 5 (6.0.1)

  1. My production environment project's targetSdkVersion was set to 15. So I used Dexter's sample to test. (Changed the targetSdkVersion to 15 in sample module's build.gradle)
  2. When I installed the app, all requesting permissions were allowed by default.
  3. Then I denied the Camera and Contacts permissions as follow. deny permission in setting
  4. I clicked the REQUEST ALL button and debugged the feedbackViewMultiplePermissionListener instance. I wanted the onPermissionsChecked(MultiplePermissionsReport report) method's parameter report giving me the right result. But the debugger's SNAPSHOT as follow: debug the report variable

Actual behaviour

Please read it in Expected behaviour section 4's SNAPSHOT.

Steps to reproduce

Please read it in Expected behaviour section 1 - 3.

Version of the library

Branch master's code with 737c419

Serchinastico commented 7 years ago

Hi @johnwatsondev

Interesting behaviour you just found here... I'm wondering if you can give us more information about the Android version of the device you were using to test.

johnwatsondev commented 7 years ago

@Serchinastico I have got a solution after did some research. I should use PermissionChecker.checkSelfPermission() check whether user granted the permission. I have tested this method on my device --- Nexus 5 (6.0.1) with targetSdkVersion 15

johnwatsondev commented 7 years ago

I thought we should just add this info to README instead of modified the AndroidPermissionService class's implement.

Because of this library was intended to check RUNTIME permission for API level more than 23. More info click here android-6.0-changes

Serchinastico commented 7 years ago

Honestly, I didn't even know of the existence of that class :scream:, we'll probably need to migrate to that API so that we don't have this problem in the future.

Thanks again for reporting back! We'll tackle the problem, one way or the other.

johnwatsondev commented 7 years ago

Here was a workaround. Please checked it. :)

@Serchinastico BTW, should we provide another util class to handle this check mission? I'm glad hear about the idea from you.

Serchinastico commented 7 years ago

I've just created a PR to address this issue, @johnwatsondev feel free to review it if you want!