B4A Library 1D and 2D Barcode Scanner with ZBAR - another Barcode Scanner that is 100% embedded in B4A

Discussion in 'Additional libraries, classes and official updates' started by Johan Schoeman, Feb 21, 2016.

  1. uniplan

    uniplan Active Member Licensed User

    I tried the library and it is fantastic.
    It is really simple to use.
    Everything works perfectly.
    The only problem is the area that displays the barcode is really very small. See picture that I attach.

    Is there a way to enlarge this area?

    Thanks.
     

    Attached Files:

    Johan Schoeman likes this.
  2. Dr. Guaranexx

    Dr. Guaranexx New Member Licensed User

    It has been a couple months since I've worked with this library, but if I recall correctly, I was able to resize the dimension of the window by using the SetLeftAndRight() and SetTopAndBottom() methods on the scanner object in the variant specific script area. I would imagine setting the width and height would work as well. If it doesn't work while setting the property in the designer, try setting it in the variant specific scripts.
     
    Last edited: Feb 22, 2017
  3. Johan Schoeman

    Johan Schoeman Expert Licensed User

    See post #51
     
  4. ByteCounter

    ByteCounter Member Licensed User

    Could someone please help with this:

    I have hopefully installed everything correctly and the sample b4aZbarBarcodeScanner compiles and runs, but I don't see any camera image on the screen (only the 3 blue buttons appear on a gray background). Clicking Start/Stop scan does nothing.
    I think this is the same problem mentioned in post #52 on Page 3. I have tried both debug & release mode, no change.

    Device is 7" tablet, Android 4.4.4

    For a beginner the install process is not given step by step, so this is what I did:
    1. ZbarBarcodeScanner_13112016.zip extracted the files ZbarBarcodeScanner.jar & ZbarBarcodeScanner.xml to additional libraries folder. (downloaded from https://www.dropbox.com/s/8e1k1zebs4jiaze/ZbarBarcodeScanner_13112016.zip?dl=0 from Post #51)

    2. zbar.jar copy to additional libraries folder (downloaded from Post #53)

    3. b4aZbarBarcodeScanner.zip example B4A project (downloaded from Post #53).

    Note I am not using a new project but the example one from Post #53

    Also, I don't understand the note in Post #1 "Please take note of the xml files in the /Objects/res/layout and Objects/res/values folders of the B4A project should you start a new project from scratch."
    Does this mean I have to copy the contents of these xml files from the example folders to my new project folder (assuming I get this thing working)?

    Thanks
     
  5. Johan Schoeman

    Johan Schoeman Expert Licensed User

    Is there any error in the B4A log? If so, can you please post it?
     
  6. ByteCounter

    ByteCounter Member Licensed User

    Hmm, I just rebooted the tablet and it now display the camera image with the scanning line.
    But there are 2 problems:

    1. Very difficult to scan barcode. Not sure if this cheap tablet has a poor camera but it is very difficult to scan even with more light and varying distance. I notice misreads sometimes too. Maybe a USB barcode scanner is better for my application.

    2. More worrying, at some point a message comes up during the app:
    "To protect you Google blocked installation of this app: Tcash
    This app is fake. It can damage your device and steal your data"
    Only started getting this after b4aZbarBarcodeScanner installed.
    Can you confirm file integrity?
     
  7. Johan Schoeman

    Johan Schoeman Expert Licensed User

    Have never seen such a message on any of my 3 x devices that I am using. The file is fine - nothing in it that will steal your data. I am too dumb to add things like that.
     
  8. Filippo

    Filippo Expert Licensed User

    Hi @Johan Schoeman ,

    First I must say that I am one of the many B4x-user of your work here is very appreciates. :)
    If I can, then I would wish that the update of your library always to the first post store, otherwise it becomes increasingly difficult to find the current version. :(
     
    Johan Schoeman and jimmyF like this.
  9. Ricardo Escalante

    Ricardo Escalante Member Licensed User

    Hello to all again, i have a little problem, i hope somebody can help me.
    Now with the changes to the android:targetSdkVersion="26", there's a new right to put in the manifest editor?
    Becose the "zar1.startScanner" does not activate the scanner.

    Sorry for my write english
     
  10. Johan Schoeman

    Johan Schoeman Expert Licensed User

    This works:

    Change your B4A Manifest to....
    Code:
    <uses-sdk android:minSdkVersion="17" android:targetSdkVersion="26"/>
    ....so that it allows for SDK 26

    Change your B4A code to:
    Code:
    #Region  Project Attributes
        
    #ApplicationLabel: ZbarBarcodeScanner
        
    #VersionCode: 1
        
    #VersionName:
        
    'SupportedOrientations possible values: unspecified, landscape or portrait.
        #SupportedOrientations: landscape
        
    #CanInstallToExternalStorage: False

    #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.
        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 zb1 As ZbarBarcodeScanner
        
    Private b1 As Button
        
    Private b2 As Button
        
    Private b3 As Button
        
    Private l1 As Label
        
    Dim frontCamId As Int
        
    Dim backCamId As Int
        
    Dim cnt As Int = 0
        
    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")
        
        
    Dim Result As Boolean = True                                                                       
        
    If Not(rp.Check(rp.PERMISSION_CAMERA)) Then                                                       
            rp.CheckAndRequest(rp.PERMISSION_CAMERA)                                                       
            
    Wait For Activity_PermissionResult (Permission As String, Result As Boolean)                   
        
    End If                                                                                             
        
    If Result Then
        
            zb1.LaserColor = 
    Colors.Yellow
            zb1.MaskColor = 
    Colors.ARGB(15000200)
            zb1.BorderColor = 
    Colors.Magenta
            zb1.BorderStrokeWidth = 
    5
            zb1.BorderLineLength = 
    40
            zb1.Visible = 
    True
            
            zb1.ScanDelay = 
    200
            
            frontCamId = zb1.FrontFacingCamera
            
    Log("frontCamId = " & frontCamId)
            backCamId = zb1.BackFacingCamera
            
    Log("backCamId = " & backCamId)
        
    Else
            
    Return
        
    End If       

    End Sub

    Sub Activity_Resume
        

    End Sub

    Sub Activity_Pause (UserClosed As Boolean)

        zb1.Visible = 
    False
        zb1.stopScanner
        
    End Sub

    Sub b1_Click
        
        zb1.toggleFlash
        
    End Sub

    Sub b2_Click
        
        zb1.Visible = 
    True   
        
    Log("trying to start scanner")
        zb1.startScanner(
    0)
        
    End Sub

    Sub b3_Click
        zb1.Visible = 
    False
        zb1.stopScanner
        
    End Sub



    Sub zb1_scan_result(scantext As String, scanformat As String)
        cnt = cnt + 
    1
        
    Log("B4A scantext = " & scantext)
        
    Log("B4A scanformat = " & scanformat)
        l1.Text = scantext & 
    " : " & cnt
        
    End Sub
    You need to enable the RuntimePermissions library in the libs tab of your IDE

    It is working on Android 8.0.0 (Samsung Experience version 9.0)
     
  11. Ricardo Escalante

    Ricardo Escalante Member Licensed User

    I really appreciate your prompt response and I regret giving you another annoying more, but when I select the library that you mention, it throws the following error.

    Thank you very much for your help
     

    Attached Files:

  12. Johan Schoeman

    Johan Schoeman Expert Licensed User

    See what this new lib files do - download them from here:
    https://drive.google.com/open?id=1vdt3jnNM9L86e3GOJNUS_FAQuJ9lOYc5

    It should show as version 1.03 in your IDE libs tab
     
  13. Ricardo Escalante

    Ricardo Escalante Member Licensed User

    I'm really sorry, but the error persists. Even when the current library is 1.03
    I'm trying to solve it on my own, but if you have time to give me any suggestions, I'll thank you very much.
     
  14. Ricardo Escalante

    Ricardo Escalante Member Licensed User

    Ready dear friends!
    Reading other post I saw this suggestion.

    Install the needed Libs in android sdk.

    Open Android SDK Manager and install the latest versions of:
    - Android Support Repository
    - Android Support Library
    - Google Play Services
    - Google Repository

    I installed it and it worked.

    Thank you very much for your help. Thanks thanks
     
    Johan Schoeman likes this.
  15. figorra

    figorra Member Licensed User

    I have this error on ZbarBarcodeScanner......



    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
    Copying updated assets files (5)
    *** Service (starter) Create ***
    ** Service (starter) Start **
    ** Activity (main) Create, isFirst = true **
    ** Activity (main) Resume **
    *** Service (httputils2service) Create ***
    ** Service (httputils2service) Start **
    ** Activity (main) Pause, UserClosed = false **
    ** Activity (escaneo) Create, isFirst = true **
    frontCamId = 1
    backCamId = 0
    ** Activity (escaneo) Resume **
    android.content.res.Resources$NotFoundException: Resource ID #0x0
    at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:216)
    at android.content.res.Resources.getColor(Resources.java:964)
    at android.content.res.Resources.getColor(Resources.java:940)
    at main.java.me.dm7.barcodescanner.core.ViewFinderView.<init>(ViewFinderView.java:39)
    at main.java.me.dm7.barcodescanner.core.BarcodeScannerView.createViewFinderView(BarcodeScannerView.java:57)
    at main.java.me.dm7.barcodescanner.core.BarcodeScannerView.setupLayout(BarcodeScannerView.java:40)
    at main.java.me.dm7.barcodescanner.core.BarcodeScannerView.setupCameraPreview(BarcodeScannerView.java:70)
    at main.java.me.dm7.barcodescanner.core.CameraHandlerThread$1$1.run(CameraHandlerThread.java:31)
    at android.os.Handler.handleCallback(Handler.java:789)
    at android.os.Handler.dispatchMessage(Handler.java:98)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:6944)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
     
  16. Johan Schoeman

    Johan Schoeman Expert Licensed User

    Sure you have all the files in the Objects/res/layout folder and in the Objects/res/values folder and the files are all set to READ ONLY?
     
  17. Schakalaka

    Schakalaka Member Licensed User

    Hello.
    i haven't understand the solution for problem on post #61.
    I have update library to version 1.0.3, but now the scanner not work anymore.
    it log "IN setAutoFocus" when i click start scanner button..
    What are the solutions?
    Thanks all.
     
  18. Johan Schoeman

    Johan Schoeman Expert Licensed User

    Can you post a sample project where it is not working?
     
  19. Schakalaka

    Schakalaka Member Licensed User

    yes there is.
    try it.
    be clear
    "not working" = "i can' t make it work with the code that i wrote"
     

    Attached Files:

    Last edited: Jun 3, 2019
    lemonisdead likes this.
  20. Johan Schoeman

    Johan Schoeman Expert Licensed User

    See if this starts the scanner. I have replaced your Main Activity with my original Main Activity code, have removed some views from your B4A layout, and commented out just about everything in your code modules. Have also replaced your b4a manifest entries. The scanner starts......

    I would suggest you start adding additional stuff bit by bit and test every step after adding additional code to make sure you can trap when and where it goes skew.

    1.png
     

    Attached Files:

Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice