Permissionsdispatcher: Requesting multiple permissions in a row results in Never ask again

Created on 15 Jun 2017  路  7Comments  路  Source: permissions-dispatcher/PermissionsDispatcher

Overview

I have an application where I need to request 3 permissions at runtime. I request them one by one like this:

@Override
protected void onStart()
{
    super.onStart();

    MainActivityPermissionsDispatcher.showLocationWithCheck(this);
    MainActivityPermissionsDispatcher.writeExternalStorageWithCheck(this);
    MainActivityPermissionsDispatcher.recordAudioWithCheck(this);
}

Expected

There are three dialogs asking if the user wants to allow each permission.

Actual

There is only one dialog, for the first requested permission, and for the other two, @OnNeverAskAgain methods are called, even if the application has been uninstalled before that.

Environment

  • Which library version are you using?
    2.4.0
  • On which devices do you observe the issue?
    Nexus 9 with Android 6.0, a few AVDs with Android 7.0, but not on one AVD with Android 6.0. I don't know why it works fine on this one virtual device...
  • Note any other information that might be useful
    There is a workaround. If I request the second permission, inside the @NeedsPermission of the first one, and in the same way with the third. So this chaining works, but if I simply ask the three permissions one after another it does not work.

Reproducible steps

inquiry

Most helpful comment

Is there any particular reason why you don't combine the three permissions into a single signature? When reaching out to the platform, Android will configure a dialog box with multiple pages, prompting each permission group one by one.

All 7 comments

Is there any particular reason why you don't combine the three permissions into a single signature? When reaching out to the platform, Android will configure a dialog box with multiple pages, prompting each permission group one by one.

Because I read this https://github.com/hotchemi/PermissionsDispatcher/issues/313#issuecomment-299823999
from which I understood that it is better to have them separate :)
Could you share why it doesn't work good in my case? Is it something in Android?

I see - generally it is a better approach to keep permission-protected methods separate, yes. Are you actually utilizing all three of those permissions right after they have been granted? In that case, bundle them together in a single request - from the specific permissions, you're maybe doing something in regards to live streaming?

If you have different features throughout the app, and each requires only one permission, consider avoiding querying everything up front. That may be an undesirable experience for users: Usually, you'd connect requesting the RECORD_AUDIO permission to a user clicking the Microphone button, and the WRITE_EXTERNAL_STORAGE somewhere else.

We need some kinds of detection for this. These consecutive method calls are not going to work.

I need these permissions for voice recognition and a map, and they are needed almost all the time, that's why I am asking upfront for all. But I consider separating them in the future when I make the voice commands optional.
Anyway, the good thing is that I managed to make it work nice with the three combined, without observing the issue described in #313 by having a common @OnShowRationale({ACCESS_FINE_LOCATION, RECORD_AUDIO, WRITE_EXTERNAL_STORAGE}) etc. methods.
So thanks for the proposal about that!

And if it does not work with consecutive method calls I would prefer to have that described in some document.

I don't think we need to have documentation for this. If you want to add that please send us PR anytime.

https://github.com/hotchemi/PermissionsDispatcher/blob/master/doc/known_issues.md

thank you guys!

Was this page helpful?
0 / 5 - 0 ratings