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);
}
There are three dialogs asking if the user wants to allow each permission.
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.
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!
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.