Android Question Check Android permission fail?

rafaelmotaquintana

Active Member
Licensed User
I have this piece of code


B4X:
    Dim r As Reflector
    Dim Api As Int
    Api = r.GetStaticField("android.os.Build$VERSION", "SDK_INT")
    If Api > 22 And (rp.Check(rp.PERMISSION_ACCESS_FINE_LOCATION) = False Or _
                     rp.Check(rp.PERMISSION_READ_EXTERNAL_STORAGE) = False Or _
                     rp.Check(rp.PERMISSION_CAMERA) = False Or _
                     rp.Check(rp.PERMISSION_READ_CONTACTS) = False Or _
                     rp.Check(rp.PERMISSION_READ_PHONE_STATE) = False)  Then
        MsgboxAsync("To continue, please allow the following permissions" & CRLF & "Para continuar, por favor acepte los siguientes permisos", "Permissions")
        Wait For Msgbox_Result (Resultx As Int)
        
        rp.CheckAndRequest(rp.PERMISSION_READ_EXTERNAL_STORAGE)
        Wait For activity_PermissionResult(permission As String, Result As Boolean)
        If Result = False Then
            Log("PERMISSION_READ_EXTERNAL_STORAGE negada")
            Return
        End If

        rp.CheckAndRequest(rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
        Wait For activity_PermissionResult(permission As String, Result As Boolean)
        If Result = False Then
            Log("PERMISSION_WRITE_EXTERNAL_STORAGE negada")
            Return
        End If

        rp.CheckAndRequest(rp.PERMISSION_CAMERA)
        Wait For activity_PermissionResult(permission As String, Result As Boolean)
        If Result = False Then
            Log("PERMISSION_CAMERA negada")
            Return
        End If
        rp.CheckAndRequest(rp.PERMISSION_READ_CONTACTS)
        Wait For activity_PermissionResult(permission As String, Result As Boolean)
        If Result = False Then
            Log("PERMISSION_CONTACTS negada")
        End If
        rp.CheckAndRequest(rp.PERMISSION_ACCESS_FINE_LOCATION)
        Wait For activity_PermissionResult(permission As String, Result As Boolean)
        If Result = False Then
            Log("PERMISSION_ACCESS_FINE_LOCATION negada")
        End If
        rp.CheckAndRequest(rp.PERMISSION_READ_PHONE_STATE)
        Wait For activity_PermissionResult(permission As String, Result As Boolean)
        If Result = False Then
            Log("PERMISSION_READ_PHONE_STATE negada")
        End If

    End If

Using Android 7, I intentionally remove some of those permissions in settings-app.
But when running the program, the rp.Check(rp.PERMISSION_CAMERA), for instance, returns TRUE, and I disabled it!.
Why it is returning true if the app has no permissions? (manually disabled)
When I run the program, if fails because it has no permissions, but (rp) returns True for all dangerous permissions. I don't understand
 
Top