Android Question [B4X] [B4XPages] Barcode Reader issue

Sergio Haurat

Active Member
Licensed User
Longtime User
Original post: [B4X] [B4XPages] Barcode Reader

I'm using the example, I just changed the code type to PDF417. This information is printed on identity documents.

The only change in the entire code:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
    toast.Initialize(Root)
    StopCamera
    B4XPages.SetTitle(Me, "Barcode Example")
    #if B4A
    CreateDetector (Array("PDF417"))

    #Else if B4i
    scanner.Initialize2("scanner", pnlPreview, Array(scanner.TYPE_93, scanner.TYPE_128, scanner.TYPE_QR))
    Wait For Scanner_Ready (Success As Boolean)
    If Success = False Then
        btnStartStop.Enabled = False
        toast.Show("Failed to initialize the scanner.")
    End If
    #end if
End Sub

This example reads it and works
1690762112464.png


This not

1690762159297.png



Logger connected to: motorola motorola edge 30 pro
--------- beginning of main
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
** Activity (main) Resume **
findCamera
null
2
facing: 0, 0
findCamera
0
2
facing: 0, 0
Preview Orientation: 90
Error occurred on line: 141 (B4XMainPage)
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:132)
at b4a.example.b4xmainpage._camera1_preview(b4xmainpage.java:398)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1114)
at anywheresoftware.b4a.keywords.Common.CallSubNew2(Common.java:1069)
at b4a.example.cameraexclass._camera_preview(cameraexclass.java:354)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
at anywheresoftware.b4a.objects.CameraW$2$1$1.onPreviewFrame(CameraW.java:147)
at android.hardware.Camera$EventHandler.handleMessage(Camera.java:1193)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loopOnce(Looper.java:238)
at android.os.Looper.loop(Looper.java:357)
at android.app.ActivityThread.main(ActivityThread.java:8118)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:957)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.hashCode()' on a null object reference
at com.google.android.gms.vision.barcode.BarcodeDetector.detect(com.google.android.gms:play-services-vision@@20.1.3:27)
... 28 more
 
Last edited:
Solution
friend and neighbor

A colleague from Argentina told me about the PDF417 DNI code.
I found this to inform me.


I have tried with Zxing and it reads PDF417 codes in images well.

example:
Picture 1:

00407821943@HAURAT@SERGIO RAUL@M@23644566@B@07/12/1973@06/11/2015@207

Image 2 (which does not read with play-services-vision)

00699849124@HAURAT@AGUSTÍN@M@49120247@A@09/10/2008@27/01/2023@206
I finally...

Sergio Haurat

Active Member
Licensed User
Longtime User
Upvote 0

Sergio Haurat

Active Member
Licensed User
Longtime User
friend and neighbor

A colleague from Argentina told me about the PDF417 DNI code.
I found this to inform me.


I have tried with Zxing and it reads PDF417 codes in images well.

example:
Picture 1:

00407821943@HAURAT@SERGIO RAUL@M@23644566@B@07/12/1973@06/11/2015@207

Image 2 (which does not read with play-services-vision)

00699849124@HAURAT@AGUSTÍN@M@49120247@A@09/10/2008@27/01/2023@206
I finally switched to Zxing, thanks for your help!
 
Upvote 0
Solution
Top