B4A Library KingsMentor/MobileVisionBarcodeScanner

A shortcut wrap for this Github project

1. Extract resource.zip and copy the folder and its contents to be on the same folder level as that of the /Files and /Objects folders of the attached B4A project.
2. Extract LibRes.zip and copy the folder and its contents to be on the same folder level as that of the /Files and /Objects folders of the attached B4A project.
3. Extract DemoRes.zip and copy the folder and its contents to be on the same folder level as that of the /Files and /Objects folders of the attached B4A project.
4. Copy the b4a lib files to your additional libs folder (jar and xml)

Touch on a highlighted barcode - the touched barcode value and value of other highlighted barcodes at the time of touch will be returned to the B4A project via an event in the B4A project.

Tested on B4A V8.30, targetSDK = 26, Android 8.0.0 (Samsung Experience Version 9.0)

Let me know if you get stuck. Will help to sort it out. But there should not be anything extraordinary to this project. Should be simple if you have your SDK updated and your paths set correctly.

Edit: Also tested with B4A v8.50 BETA and working ;)



Github: KingsMentor, Wrapped by: Johan Schoeman
Version: 1.02
  • KingsMentor
    • scan_result (data As Object, closeby As String)
    • BeginScan As void
    • IsInitialized As boolean
    • Initialize (paramBA As anywheresoftware.b4a.BA, paramString As java.lang.String) As void
    • BarcodeTextSize As float [write only]
    • BarcodeRectangleStrokeWidth As float [write only]

Sample Code:

#Region  Project Attributes
    #ApplicationLabel: b4aKingsMentor
    #VersionCode: 1
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: portrait
    #CanInstallToExternalStorage: False
#End Region

#AdditionalRes: ..\DemoRes
#AdditionalRes: ..\LibRes
#AdditionalRes: ..\resource

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Dim 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 Button1 As Button
    Dim km As KingsMentor
    Private Label1 As Label
    Private Label2 As Label
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    km.BarcodeTextSize = 40.0
    km.BarcodeRectangleStrokeWidth = 15.0
    Label1.Visible = False
    Label2.Visible = False

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub Button1_Click

    Label1.Visible = False
    Label2.Visible = False
    Dim Result As Boolean = True
    If Not(rp.Check(rp.PERMISSION_CAMERA)) Then
        Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
    End If
    If Result Then
    End If
End Sub

Sub junk_scan_result(data As Object, closeby As String)
'   Log(" ")
'   Log("closest code touched = " & closeby)
'   Log(" ")
   Label1.Visible = True
   Label1.Text = "Barcode clicked : " & closeby
   Label2.Visible = True
   Label2.Text = "Barcodes highlighted when touched:"

   Dim finalstring As String = ""
   Dim mylist As List = data
   For i = 0 To mylist.Size - 1 Step 3
'        Log("barcode value : " & mylist.Get(i))
'     Log("barcode type  : " & mylist.Get(i+1))
'     Log("barcode data  : " & mylist.Get(i+2))
'     Log(" ")
        finalstring = finalstring & mylist.Get(i+2) & Chr(10)
   Label2.Text = Label2.Text & Chr(10) & Chr(10) & finalstring
End Sub


  • LibRes.zip
    2 KB · Views: 228
  • resource.zip
    423 bytes · Views: 220
  • b4aKingsMentor.zip
    8.9 KB · Views: 208
  • DemoRes.zip
    57.7 KB · Views: 197
  • b4aKingsMentorLibFiles.zip
    51.6 KB · Views: 217
Last edited:

Johan Schoeman

Licensed User
Earlier today I have updated my B4A from v9.00 to v9.30 and then from v9.30 to v9.50
I tested my project in post #1 but got an error. Browsing around in the B4X forum I found the solution - the layout file (activity_main.xml) in folder DemoRes required some changes in some places from




The library will be "jetified" if you select Tools->Jetifier (AndroidX) as the wrapper uses:

@DependsOn(values={"com.android.support:support-v4", "com.android.support:appcompat-v7", "com.google.android.gms:play-services-vision", "com.android.support:design"})

Attached is the updated DemoRes folder (zipped). Once extracted, replace the original DemoRes folder (i.e the one in post #1) with the attached folder.

Tested and working on Android 9 (Galaxy S10) with B4A v9.50 after SDK update and running the Jetifier.



  • DemoRes_b4a9.30.zip
    57.7 KB · Views: 142
Last edited: