Android Question Cross platform example - best practice for RuntimePermissions?

Alexander Stolte

Expert
Licensed User
Longtime User
I'm building on this tutorial:

what is the best way to call the Runtime Permissions, since they only work in an Activity?
I have a button that only asks for permission when he presses this button (save image in gallery), if he does not click this button he does not need this permission.

Greetings
 

MicroDrie

Well-Known Member
Licensed User
Edit: The general advice is always check run time permission just before you your app need it and not in an Activity_Resume. Without seeing any code, I should say in the processing of the button click logic. You can find the details in Runtime Permissions (Android 6.0+ Permissions) post.
 
Last edited:
Upvote 0

JohnC

Expert
Licensed User
Longtime User
I would also recommend giving a detailed, but simple explanation of why your app needs a particular permission before prompting, because the pop-up text that the OS shows a user is often confusing.

The below code does this easily and gracefully:

 
Last edited:
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
The general advice is always check run time permission just before you need it and not in an Activity_Resume.
No, only ask a user for a permission if the app need it!

I don't think that is need a description if the user press the save in gallery button.

I have already successfully integrated the permissions into my app, my problem is to call the runtime permissions from a class, because you cannot make a wait for, for functions that are in another module.
 
Upvote 0

MicroDrie

Well-Known Member
Licensed User
No, only ask a user for a permission if the app need it!
You are right, it is not you but your app. I have change my statement.

I don't think that is need a description if the user press the save in gallery button.
Till the user withdraws his permission, the user will only see once the permission request. Personally I think that transparency is on the long run the best approach to tell the user why the permission is requested. It gives also the opportunity to explain the consequences when it is not given.

I have already successfully integrated the permissions into my app, my problem is to call the runtime permissions from a class, because you cannot make a wait for, for functions that are in another module.
Perhaps you could find inspiration in the post Wait for in class module to solve your challenge for functions that are in another module.
 
Upvote 0
Top