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?
B4A + B4i barcode reader. Don't miss: - #PlistExtra in B4i. - Manifest code + #AdditionalJar in B4A Depends on BCToast: https://www.b4x.com/android/forum/threads/b4x-bctoast-cross-platform-custom-toast-message.111046/#content (BCToast will be an internal library in the near future) While the...
www.b4x.com
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
B4A + B4i barcode reader. Don't miss: - #PlistExtra in B4i. - Manifest code + #AdditionalJar in B4A Depends on BCToast: https://www.b4x.com/android/forum/threads/b4x-bctoast-cross-platform-custom-toast-message.111046/#content (BCToast will be an internal library in the near future) While the...
www.b4x.com
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
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?
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.