B4A Library Another B4A Barcode Scanner - based on Android Vision

Sure you will figure it out - check the B4A log when scanning a barcode

Copy the .jar and .xml files to your B4A additional libs folder.

B4A code:

B4X:
#Region  Project Attributes
    #ApplicationLabel: jhsScanOnly
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: portrait
    #CanInstallToExternalStorage: False
'    #MultiDex: True

#End Region


#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.
    
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 bs1 As BillScanner
    Private Button1 As Button

End Sub

Sub Activity_Create(FirstTime As Boolean)
    
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("main")
    
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)
    
      bs1.stopScanning
      
End Sub

Sub bs1_scan_value(val As String, rawbyte() As Byte, barcodetype As Int)
    
    Log("Value = " & val)
    Log("type = " & barcodetype)
    Log(" ")
    
End Sub

Sub Button1_Click
    
    bs1.startScanning
    
End Sub

I guess you know how to make this "RuntimePermissions" compliant.

Take note of this in the B4A Manifest file:

B4X:
AddApplicationText(<meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />
        <meta-data
            android:name="com.google.android.gms.vision.DEPENDENCIES"
            android:value="barcode" />)

This is the scanner that I am using here.....


Zxing does not work - this scanner (based on Android Vision) does the job.

Enjoy.....;)
 

Attachments

  • BillScanner.xml
    9.3 KB · Views: 764
  • BillScanner.jar
    4.4 KB · Views: 793
  • jhsScanOnly.zip
    9.9 KB · Views: 861

Xfood

Expert
Licensed User
Call bs1.stopScanning in Sub bs1_scan_value(val As String, barcodetype As Int) when you got a result and you want the scanner to stop scanning.
if you look at the example above, in fact I do so, but it still reads the code twice post #11

with your makeup I should solve.

could you add this effect when reading?
 

Attachments

  • lettore-codici-a-barre.jpg
    lettore-codici-a-barre.jpg
    18.8 KB · Views: 211

Johan Schoeman

Expert
Licensed User
Longtime User
if you look at the example above, in fact I do so, but it still reads the code twice post #11

with your makeup I should solve.

could you add this effect when reading?
 

Xfood

Expert
Licensed User
I'm trying the link suggested by you,
It is great, but too complicated only for the reading of barcode,
Do you have an example with a Start key, which activates only the barcode reading, and just reads me from the Scan_Result?
scan_start
scan_stop
scan_result (val As String, barcodetype As Int)
 
Top