Android Question [SOLVED] [B4X] [B4XPages] Barcode Reader - when running app get black rectangle

Mark Stuart

Active Member
Licensed User
Longtime User
Hi all,
I'm implementing Erel's BARCODE READER into my app and the added feature is running without error.
But when I tap the START button, all I get is a black rectangle with no camera picture. I then tap the button again (STOP) and the rectangle (Panel) disappears as expected.
I put a debug on some of the code to step thru the code, and the camera picture appeared. Hovering over the barcode, the code "captured" the barcode as expected.

Initially, I downloaded the demo app and ran it without error and it ran as expected, with none of the above issues, it works perfectly.

My device (Samsung 23Plus) has 3 back cameras and the code reports 3 cameras in my app and the demo app.
Here are the Log results from my app:

B4X:
findCamera
null
3
facing: 0, 0
findCamera
0
3
facing: 0, 0
Preview Orientation: 90
Camera Success
** Activity (scanitems) Pause, UserClosed = true **
** Activity (select_zone) Resume **

So I need to figure out why the camera picture does not appear while running it.
Any help on this would be appreciated.

BTW... I did copy the #AdditionalJar to the Main and copied in the Manifest additions as well.
UPDATE #1: after running the app in debug mode and stepping thru the code, I see the camera picture starts/appears with the following CameraExClass function:
B4X:
Public Sub StartPreview
    cam.StartPreview     '<--- right here
End Sub
So now why doesn't the camera picture start without stepping thru the code?

UPDATE #2: added a Sleep(100) as follows and now the camera picture appears as expected and the code reads the barcode as expected.
B4X:
Public Sub StartPreview
    Sleep(100)            '<--- added this seems to work on the Samsung S23Plus device
    cam.StartPreview
End Sub

Regards,
Mark Stuart
 
Last edited:

Mark Stuart

Active Member
Licensed User
Longtime User
I now have my re-built Inventory Scan app working with @Erel's Barcode Reader (the original app I built has been in use since 2015).

On the new Scan Items layout, is placed the panel that displays the pnlPreview. It lays over the CLV that holds the scanned items.
To display the pnlPreview, I had to hide (Visible=False) the CLV which is in a Panel with Elevation=5. So actually, I'm hiding the Panel, then showing the pnlPreview when tapping the Start button (btnStartStop).
I also issue the StopCamera is the FoundBarcode function. So the reverse happens to the pnlPreview and the CLV panel.
This speeds up the scanning process quite a bit - less for the user to do.

The initial test run of the new layout the pnlPreview did not appear, so that's when I figured out hide and show the appropriate views.
All is working as I anticipated.

Thanx @Erel for the CameraExClass class and the demo app.

ADDITIONAL - to test the barcode scanning in the new built app, I created another app that generates the barcode. This app runs on my tablet and the Inventory Scan app is running on my Samsung 23Plus phone.
BTW - the CamerExClass has no problem reading digital screens with barcodes on it.

This additional barcode generating app will eventually print the barcodes to a Zebra ZD410 label printer. My next challenge.
For the legacy Inventory Scan app, I built a complimentary VB.NET app that allowed the user to print the item barcodes to a Zebra 2428 Plus label printer.
All this was running in 22 locations.

Now I get to introduce them to new app versions of printing and scanning barcodes.
I'm hoping the management realize that all this can be done on a device the size of a cell phone.

We having fun yet?

Regards,
Mark Stuart
 
Upvote 0
Top