B4A Library MaterialBarcodeScanner (Uses Google Mobile Vision API)

This is a wrap for this github project.

Easy to use barcode reader for your Android Project (Uses Google Mobile Vision API)
  • Integrate in a few minutes
  • Quick and simple api
  • No external apps required
  • Uses Google Mobile Vision API (fast scanning, local)
  • Automatically parses QR Codes, Data Matrix, PDF-417, and Aztec values
  • Supports 1D barcodes: EAN-13, EAN-8, UPC-A, UPC-E, Code-39, Code-93, Code-128, ITF, Codabar
  • Supports 2D barcodes: QR Code, Data Matrix, PDF-417, Aztec

MaterialBarcodeScanner
Author:
DonManfred (wrapper)
Version: 1
  • BarcodeScanner
    Methods:
    • Initialize (EventName As String)
    • IsInitialized As Boolean
    • startScan
      Start a scan for a barcode

      This opens a new activity with the parameters provided by the MaterialBarcodeScannerBuilder
  • BarcodeScannerBuilder
    Events:
    • onResult (barcode As String)
    Methods:
    • BleepEnabled (enabled As Boolean) As MaterialBarcodeScannerBuilderWrapper
      Enables or disables a bleep sound whenever a barcode is scanned
    • CameraFacing (cameraFacing As Int) As MaterialBarcodeScannerBuilderWrapper
      Either CameraSource.CAMERA_FACING_FRONT or CameraSource.CAMERA_FACING_BACK
      cameraFacing:
    • EnableAutoFocus (enabled As Boolean) As MaterialBarcodeScannerBuilderWrapper
      Enables or disables auto focusing on the camera
    • FlashLightEnabledByDefault As MaterialBarcodeScannerBuilderWrapper
      Shows a text message at the top of the barcode scanner
    • Initialize (EventName As String) As MaterialBarcodeScannerBuilderWrapper
    • IsInitialized As Boolean
    • Text (text As String) As MaterialBarcodeScannerBuilderWrapper
      Shows a text message at the top of the barcode scanner
    • TrackerColor (color As Int) As MaterialBarcodeScannerBuilderWrapper
      Sets the tracker color used by the barcode scanner, By default this is Material Red 500 (#F44336).
      color:
    • build As MaterialBarcodeScanner
      Build a ready to use MaterialBarcodeScanner
      Return type: @return:A ready to use MaterialBarcodeScanner
    • withBackfacingCamera As MaterialBarcodeScannerBuilderWrapper
      Makes the barcode scanner use the camera facing back
    • withFrontfacingCamera As MaterialBarcodeScannerBuilderWrapper
      Makes the barcode scanner use camera facing front

ATTENTION:
- You need to have google-play-services.jar in your additional libs folder
- You need to have android-support-v4.jar in your additional libs folder
- You need to have android-support-v7-appcompat..jar in your additional ibs folder. Especially the app must be prepared to use AppCompat. So follow the apcmpat tutorial.

I´ve used Example1 of the AppCompat-Tutorials and used the Button in the layout to trigger a Barcodescan

See it in action
 

Attachments

  • MaterialBarcodeEx.zip
    34.6 KB · Views: 1,222
  • MaterialBarcodelibfiles1.0.0.zip
    84.1 KB · Views: 1,148
  • MaterialBarcodeScannerV1.5.zip
    88.2 KB · Views: 1,010
Last edited:

DonManfred

Expert
Licensed User
Longtime User
Tried a Samsung 8" Tablet (SM-T335). It does not recognize a barcode here. No crash but no detection.
 

Johan Schoeman

Expert
Licensed User
Longtime User
Tried a Samsung 12,1" Tablet (SM-P900). Works fine.
Works perfectly on my 7" Samsumg GT-P3100 with Android 4.0.4 with the change that I have made as per post #20
Also now working on my Samsung S4 mini with KitKat
 

Wolli013

Well-Known Member
Licensed User
Longtime User
Samsung S3 work fine with

<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat"/>

<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>

<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

</resources>

Samsung4 Tab not work, not Autofocus!
 

Douglas Farias

Expert
Licensed User
Longtime User
hi @DonManfred
i will test this lib on my new project, if works fine i will donate for u, very good work.
You know what the minSdkVersion of this lib?

thx
 

Johan Schoeman

Expert
Licensed User
Longtime User

incendio

Well-Known Member
Licensed User
Longtime User
Is this lib need to run with appcompat?

I tried without it, my codes only like these
B4X:
Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("b4a4lay1")
End Sub

Layout is from this example. I have google-play-services.jar, android-support-v4.jar & android-support-v7-appcompat.jar in my Lib folder.
Libraries are Core & MaterialBarcodeScanner ver 1.00, got these error.

B4A version: 5.80
Parsing code. (0.00s)
Compiling code. (0.02s)

ObfuscatorMap.txt file created in Objects folder.
Compiling layouts code. (0.01s)
Generating R file. (0.04s)
Compiling generated Java code. (1.13s)
Convert byte code - optimized dex. Error
UNEXPECTED TOP-LEVEL ERROR:
java.lang.OutOfMemoryError: GC overhead limit exceeded
at com.android.dx.ssa.back.SsaToRop.convertBasicBlock(SsaToRop.java:322)
at com.android.dx.ssa.back.SsaToRop.convertBasicBlocks(SsaToRop.java:259)
at com.android.dx.ssa.back.SsaToRop.convert(SsaToRop.java:123)
at com.android.dx.ssa.back.SsaToRop.convertToRopMethod(SsaToRop.java:69)
at com.android.dx.ssa.Optimizer.optimize(Optimizer.java:101)
at com.android.dx.ssa.Optimizer.optimize(Optimizer.java:72)
at com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:299)
at com.android.dx.dex.cf.CfTranslator.translate0(CfTranslator.java:139)
at com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.java:94)
at com.android.dx.command.dexer.Main.processClass(Main.java:613)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:570)
at com.android.dx.command.dexer.Main.access$2(Main.java:546)
at com.android.dx.command.dexer.Main$2.processFileBytes(Main.java:514)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:537)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:449)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:236)
at com.android.dx.command.dexer.Main.run(Main.java:206)
at com.android.dx.command.dexer.Main.main(Main.java:179)
at com.android.dx.command.Main.main(Main.java:103)
 

roberto64

Active Member
Licensed User
Longtime User
you quelo trial, error
"builder.setText("DonManfred presents") builder.setTrackerColor(Colors.Red)"
scanner = builder.Initialize("Barcode").BleepEnabled(True).EnableAutoFocus(True).withBackfacingCamera.setText("DonManfred presents").setTrackerColor(Colors.Red).build"
Version lib MaterialBarcodeScanner v1.01
 

roberto64

Active Member
Licensed User
Longtime User
This and error, I apologize for my English, only co translator
regards
 

Attachments

  • ERRore.jpg
    ERRore.jpg
    258.6 KB · Views: 411

DonManfred

Expert
Licensed User
Longtime User
Upload your project please. In the ide under File-Export as zip
i dont like to see images as problem but no code!

Are the two maven repos up-to-date?
Which version of the lib are you using? 1.5 is uptodate

I just can say; i tried my example above and it is working here.
 
Top