Android Question Runtime Permissions - rp.check

RJB

Active Member
Licensed User
Longtime User
Runtime permission requests just ask the user to allow or deny a permission. There is no explanation as to why it is needed. I'd like to add an explanation before the request so using rp.check to find out if the permission has already been granted seems like the way to go. However I can't find any information on rp.check, is it something like:
B4X:
  rp.Check(rp.PERMISSION_ACCESS_FINE_LOCATION)
  Wait For Activity_CheckResult (Permission As String, Result As Boolean)
  If (Permission = rp.PERMISSION_ACCESS_FINE_LOCATION) And (Result = False) Then
        'explain the reason and request permission
         .......
  end if

Thanks
 

DonManfred

Expert
Licensed User
Longtime User
There is another method named Check that only tests whether the permission has already been approved or not. This method can be called from any module.
It might be tempting to first test whether there is a permission and only if there is no permission call CheckAndRequest. However it will just make the program flow more complicated as you will need to deal with all cases anyway.
As a general rule, you shouldn't call RuntimePermissions.Check from an Activity. It will be simpler to always call CheckAndRequest.
 
Upvote 0
Top