B4A Library ZXING Barcode Scanner - A wrap for the official ZXING project as it is on 10 July 2016

Always wanted to do this one....This is a wrap for the official ZXING barcode scanning project as what it is today (i.e 10 July 2016). I have compiled the core part of the project, the front end of the project, and the wrapper all into a single jar file.

Note:
1. You can switch on/off the flash/torch by making use of the volume up/down buttons of your device
2. See the folder \resource_zxing in the B4A folder structure
3. Take note of the B4A Manifest file
4. I have added no code whatsoever to return anything to the B4A project (this can easily be done)
5. It supports a range of different languages depending on what language your device has been set too. See the values-xxx folders in the B4A project's \resource_zxing folder for supported languages

5.png


8.png



Have tested it with scans of the following 1D and 2D barcodes:
UPC_E
EAN_13
EAN_8
RSS_14
RSS_EXPANDED
CODE_39
CODE_93
CODE_128
ITF
CODABAR
QR_CODE
DATA_MATRIX
PDF_417
AZTEC_CODE

You can download the whole lot from HERE:
1. B4A project
2. B4A Library files - copy them to your additional library folder
3. The java code.

Click on your device's MENU button once the scanner has started. Then select SETTINGS. There are a vast number of setting that you can set....

6.png


7.png


Take it for a test drive....;)

Sample code:

B4X:
#Region  Project Attributes
    #ApplicationLabel: ZxingMaster - Wrapped by Johan Schoeman
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

'#AdditionalRes: ..\resource
#AdditionalRes: ..\resource_zxing

'IMPORTANT!!!! YOU NEED TO SET THIS PATH CORRECTLY FOR YOUR OWN COMPUTER!!!!!!!!!!!!!!!!!!
'THE BELOW PATH IS THE PATH FOR MY COMPUTER
'#AdditionalRes: C:\ANDRIOD_SDK_TOOLS\extras\android\support\v7\appcompat\res, android.support.v7.appcompat
'#Extends: android.support.v7.app.AppCompatActivity

#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 Button1 As Button
    Private Label1 As Label
    Dim myscanner As ZxingMaster


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")
    myscanner.Initialize("mycam")
    Label1.Visible = True
    Label1.Text = "Wrapped by Johan Schoeman"

End Sub

Sub Activity_Resume


End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub Button1_Click

  myscanner.StartZxingMaster

End Sub

0.png



1.png


2.png


Library as it stands at present:
ZxingMaster
Author:
Github: Sean Owen , Wrapped by: Johan Schoeman
Version: 1
  • ZxingMaster
    Methods:
    • Initialize (paramString As String)
    • IsInitialized As Boolean
    • StartZxingMaster
    Permissions:
    • android.permission.ACCESS_WIFI_STATE
    • android.permission.CAMERA
    • android.permission.CHANGE_WIFI_STATE
    • android.permission.FLASHLIGHT
    • android.permission.INTERNET
    • android.permission.READ_CONTACTS
    • android.permission.VIBRATE
    • android.permission.WRITE_EXTERNAL_STORAGE
    • com.android.browser.permission.READ_HISTORY_BOOKMARKS
 
Last edited:

agraham

Expert
Licensed User
Longtime User
This may not apply in your case but you must use Java 8 to compile with SLC because BADoclet can produce incorrect XML with Java 11 or later. SLC uses the Java from the B4A IDE path setting.

Erel said a long time ago that he would fix this but it hasn't happened yet!.
 
Top