I have this code in an activity:
(I'm using rp.Check because I want to explain the permission a little better to the user before actually requesting it.)
The problem is that the Activity_PermissionResult event is never raised. (I've also tried this as its own sub, not using Wait For.) It's really strange, because in another place in the app I request permission to use the GPS, and that works just as expected.
I'm sure I've just made a blunder somewhere, but I just can't seem to find it. Can someone spot the problem?
B4X:
Sub theButton_Click
' Have we permission to use camera?
Private rp As RuntimePermissions
Private havePermission As Boolean = True
If Not(rp.Check("android.permission.CAMERA")) Then
Msgbox("We need this permission because reasons so press Allow.", "Important info")
rp.CheckAndRequest("android.permission.CAMERA")
Wait For Activity_PermissionResult (Permission As String, havePermission As Boolean)
End If
' Exit early if permission wasn't granted
If Permission = "android.permission.CAMERA" And Not(havePermission) Then
ToastMessageShow("Sorry, can't continue, press button to try again.", True)
Return
End If
' We have the permission so go ahead
cameraCodeGoesHere
End Sub
(I'm using rp.Check because I want to explain the permission a little better to the user before actually requesting it.)
The problem is that the Activity_PermissionResult event is never raised. (I've also tried this as its own sub, not using Wait For.) It's really strange, because in another place in the app I request permission to use the GPS, and that works just as expected.
I'm sure I've just made a blunder somewhere, but I just can't seem to find it. Can someone spot the problem?