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

Requesting Permission After cancelPermissionRequest #170

Closed eygraber closed 7 years ago

eygraber commented 7 years ago

If I call PermissionToken.cancelPermissionRequest how can I get the library to start making permission requests for that permission again?

pedrovgs commented 7 years ago

@eygraber did you try invoking this?

Dexter.withActivity(activity)
            .withPermission(permission)
            .withListener(listener)
            .check();

or invoking token.continuePermissionRequest(); instead of PermissionToken.cancelPermissionRequest?

eygraber commented 7 years ago

Here's the flow for cancelPermissionRequest:

  1. Dexter.withActivity(activity).withPermission(permission).withListener(listener).check();

  2. In the rationale callback I call token.cancelPermissionRequest()

  3. I later call Dexter.withActivity(activity).withPermission(permission).withListener(listener).check(); again but the permission dialog is not shown

Flow for continuePermissionRequest:

  1. Dexter.withActivity(activity).withPermission(permission).withListener(listener).check();

  2. In the rationale callback I call token.continuePermissionRequest()

  3. I later call Dexter.withActivity(activity).withPermission(permission).withListener(listener).check(); and the permission dialog is shown

pedrovgs commented 7 years ago

If you invoke token.cancelPermissionRequest() you are telling the library the user doesn't want to accept your permission and the library won't show the final dialog. This is the expected behavior. If you want to show the Android native dialog always you should invoke token.continuePermissionRequest().

If you think there is something wrong with the lib or you've found a bug, it could be great if you create an example project and explain your expected behavior. Based on this we'll be able to easily give you feedback or fix the bug 😃

eygraber commented 7 years ago

I see. I think that's a cool feature, but there should be a way to reverse it if necessary. Otherwise we can never ask the user for that permission again.

pedrovgs commented 7 years ago

@eygraber the Google permissions systems works like this. The idea of the token is that you can show some feedback to the user explaining why you are going to ask for that permission. The user experience designed by google is something we can't change from our library even when we'd like 😃

I guess you've got the answer to your question, so I'm closing this issue. Thanks!

eygraber commented 7 years ago

That's not really accurate, because with Google we can direct the user to the app settings to manually turn the permission on. With this, there's no way to go back. So even if the user didn't check the "Don't ask again" on the permission prompt, I can't ask them again.

pedrovgs commented 7 years ago

Showing a rationale dialog while asking for the permission is not mandatory. You don't even have to ask for a yes/no question and just show a dialog saying "we need this permission because...". If I'm not wrong, this is more related to the UX than the library it self. @Serchinastico any other thought?

anggrayudi commented 3 years ago

@eygraber the Google permissions systems works like this. The idea of the token is that you can show some feedback to the user explaining why you are going to ask for that permission. The user experience designed by google is something we can't change from our library even when we'd like 😃

I guess you've got the answer to your question, so I'm closing this issue. Thanks!

Can you give the reference link where Google said it?

pedrovgs commented 3 years ago

https://developer.android.com/training/permissions/usage-notes#:~:text=developing%20Android%20applications.-,Permissions%20in%20Android%206.0%2B,data%20protected%20by%20the%20services.