Android Question B4Pages - Camera id management

Cableguy

Expert
Licensed User
Longtime User
Hi guys,

I'm using the B4Pages barcode reader example as a base for an app idea...
Si my issue here is that if I leave the app by pressing the home button, the camera is stopped... normal.. but if I re-launch the app, I lose the camera id and thus no preview image...
Any ideas?
 
Last edited:
Solution

Add this code to start preview automatically if the user has already gave permission:
B4X:
Private Sub B4XPage_Appear
    If Capturing = False And rp.Check(rp.PERMISSION_CAMERA) Then
        StartCamera    
    End If
End Sub

Erel

B4X founder
Staff member
Licensed User
Longtime User

Add this code to start preview automatically if the user has already gave permission:
B4X:
Private Sub B4XPage_Appear
    If Capturing = False And rp.Check(rp.PERMISSION_CAMERA) Then
        StartCamera    
    End If
End Sub
 
Upvote 0
Solution

Cableguy

Expert
Licensed User
Longtime User
Thanks @Erel,

Just tried it and it works perfect.
So my error was not checking if camera permission had already been given and not asking for it again... right?
In my app I want to skip the "start" button completly and build some overlays over the preview image, that will be fullscreen.
Any heads-up advice?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Not exactly. The new code calls rp.Check which only checks whether the permission was already granted. In most cases we use rp.CheckAndRequest.

So if we already have permission, we start the camera immediately. Otherwise we let the user click on the start button. This gives better user experience.
 
Upvote 0
Top