Android Question Pemission to Back Camera & Front Camera

AndroidMadhu

Active Member
Licensed User
Hello,
I want to provide permission both front & Back camera.
But I cannot initialize both the camera.
Below is my codes
B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Private rp As RuntimePermissions

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Private phonecam As Camera
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("MainPermission")
    phonecam.Initialize     <=== Here I am facing issue
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


Sub Button1_Click
    rp.CheckAndRequest(rp.PERMISSION_CAMERA)
End Sub

Sub Permission_result(Permission As String, Result As Boolean)
    If Permission=rp.PERMISSION_CAMERA Then
        phonecam=Result  <==What will b the properties for phonecam
    End If
End Sub
 

AndroidMadhu

Active Member
Licensed User
My Idea is like when the app is installed all the permission will be asked. Then App will be installed.
I have followed @Erel example but not working...

B4X:
Sub Activity_Resume
    For Each permission As String In Array(rp.PERMISSION_CAMERA, rp.PERMISSION_READ_CONTACTS,rp.PERMISSION_SEND_SMS)
        rp.CheckAndRequest(permission)
        Wait For Activity_PermissionResult (permission As String, Result As Boolean)
        If Result=False Then
            ToastMessageShow("No permission!",True)
            Activity.Finish
            Return
        End If
    Next
End Sub
 
Upvote 0

AndroidMadhu

Active Member
Licensed User
I have created a layout and One button I have placed. On click event I am trying to pass all the permissions. But no Luck.
Please find the log files
B4X:
Logger connected to:  Xiaomi Redmi 6A
--------- beginning of crash
--------- beginning of main
Copying updated assets files (1)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
sending message to waiting queue (activity_permissionresult)
running waiting messages (1)
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = true **
** Service (starter) Destroy (ignored)**
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
sending message to waiting queue (activity_permissionresult)
running waiting messages (1)
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = true **

Please advice
 
Upvote 0
Top