B4A Library ZXingLib by icefairy333 - modified by Johan Schoeman (Scan QR Codes and other 1D/2D Barcodes)

ScannerActive.png


See the attached project (with library files in the /files folder of the project). This is based on the original work of @icefairy333. I have modified @icefairy333's library so that it can do the following:

1. Set the color of the border of the framing rectangle from B4A code
2. Set the color of the laser from B4A code
3. Set the color of the mask around the framing rectangle from B4A code
4. Set the color of the result points from B4A code
5. Set the color of the final panel being displayed before control is being returned to the B4A project from B4A code
6. Ability to switch on/off the torch when making use of the back camera scanner by means of the volume up/down buttons. Use the volume up/down buttons to toggle the torch on/off when the scanner is active.

a. It retains the Portrait /Landscape option as per @icefairy333 's version 1.5 posted in post #1 of his original post.
b. It retains use of the front / back camera (not sure if it supports all types of devices)

See post #5 for changes that might be required to the Manifest of the project.

Edit: Posting JohanIceFairyZxingWidthMod.zip that will allow you to change the width / height of the ViewFinder. New library files are in the /files folder of the attached project. Replace the old lib files with the new ones.

Edit: Posting JohanIceFairyZxingWidthModAndTextMod.zip that will allow you also add text to the mask around the viewfinder of the scanner.

Edit: Posting JohanIceFairyZxingWidthTextBitmap.zip that will allow you to also add a bitmap to the mask around the viewfinder of the scanner.

Edit: Posting JohanIcefairyZxingWidthTextBitmapTouchTorch.zip that retains all previously added functionality but you can now also switch on/off the flash when using the back camera by either using the volume up/down buttons or just touch the screen while the scanner is active.

Edit: attached file src.zip contains the java source code. It can be compiled into a B4A library with Simple Library Compiler (SLC) as is, provided you set up the directory structure correctly and you set up SLC correctly. See elsewhere in this thread how to do it.

Edit: Attached JohanIcefairyZxingTimeout.zip with all the previously added functionality but adding an option to specify a timeout duration. Default timeout duration is 15 seconds (should you not specify any timeout duration). Also posting src_2.zip with the amended java source code

eg of Button1_Click for project in JohanIcefairyZxingTimeout.zip
B4X:
Sub Button1_Click
  zx.isportrait = True
  zx.useFrontCam = False

  'set the timeoutDuration to a very high value (such as 2000000000) if you dont want it to time out
  '2000000000 = 63 years+
  zx.timeoutDuration = 30

  'change these factors between 0 and 1 to change the size of the viewfinder rectangle
  'the library will limit the minimum size to 240 x 240 pixels and the maximum to (screen width) x   (screen height) pixels
  zx.theViewFinderXfactor = 0.7
  zx.theViewFinderYfactor = 0.5

  zx.theFrameColor = Colors.Blue
  zx.theLaserColor = Colors.Yellow
  zx.theMaskColor = Colors.argb(95, 0, 0, 255)
  zx.theResultColor = Colors.Green
  zx.theResultPointColor = Colors.Red

  'set the prompt messages
  zx.theTopPromptMessage = "This was done......"
  zx.theTopPromptTextSize = 5%y'text size in pixels
  zx.topPromptColor = Colors.Red
  zx.topPromptDistanceFromTop = 1%y'pixel distance from top

  zx.theBottomPromptMessage = "Just for fun......"
  zx.theBottomPromptTextSize = 5%y'text size in pixels
  zx.bottomPromptColor = Colors.Blue
  zx.bottomPromptDistanceFromBottom = 5%y'pixel distance from top

  'add a bitmap
  zx.theBitMap = bm
  zx.theBitMapLeft = 40%x
  zx.theBitMapTop = 10%y
  zx.theBitMapWidth = 20%x
  zx.theBitMapHeight = 20%x

  zx.BeginScan("myzx")
End Sub

Enjoy!
 

Attachments

  • JohanIcefairyZxing.zip
    416.8 KB · Views: 1,984
  • JohanIcefairyZxingWidthMod.zip
    417.5 KB · Views: 1,339
  • JohanIcefairyZxingWidthModAndTextMod.zip
    418.4 KB · Views: 1,271
  • JohanIcefairyZxingWidthTextBitmap.zip
    421 KB · Views: 1,206
  • JohanIcefairyZxingWidthTextBitmapTouchTorch.zip
    421.5 KB · Views: 1,320
  • JohanIcefairyZxingTimeout.zip
    421.5 KB · Views: 1,355
  • b4aZXINGusingVer1.05.zip
    12.2 KB · Views: 1,063
  • JhsIceZxing1Ver1.05.zip
    444.1 KB · Views: 1,100
  • JhsIceZxing1Ver1.06.zip
    444.1 KB · Views: 1,711
Last edited:

Johan Schoeman

Expert
Licensed User
Longtime User
I
Hi!
This library worked flawlessly on my phone previously, but now (i think after Android 6.0.1 update) it exits from the app immediately after scan. It doesn't fire xxx_result. I don't see any relation with the torch. I have a Note4, but it's also doesn't work on a fresh updated S7. I'm using it in portrait mode, if it counts.
Please help.
Thanks!

I don't have an android 6.xx device so cant test to see what is the issue that you have with the scanner and xxx_result not firing. It is working on my KitKat and Lollipop devices....
 

Johan Schoeman

Expert
Licensed User
Longtime User
This was requested via a PM. Ability to move the laser up/down while the scanner is active.

Attached new B4A lib files and a sample B4A project - copy the lib files (xml and jar) to your additional library folder.

Use the laser up/down like this:
B4X:
zx.moveLaser = True

Sample Code:
B4X:
#Region Module Attributes
    #FullScreen: False
    #IncludeTitle: True
    #ApplicationLabel: b4aZXING
    #VersionCode: 1
    #VersionName:
    #SupportedOrientations: portrait
    #CanInstallToExternalStorage: False
#End Region

'Activity module
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.
    Dim zx As JhsIceZxing1
    Private Button1 As Button
    
   
    Dim bm As Bitmap
   
    Dim ImageView1 As ImageView
    Private ImageView2 As ImageView
    Private ImageView3 As ImageView
    Private ImageView4 As ImageView
    Dim cnt As Int
    Private ImageView5 As ImageView

End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("main")
    bm.Initialize(File.DirAssets,"B4A.png")
    ImageView1.Color = Colors.Transparent
    ImageView2.Color = Colors.Transparent
    ImageView3.Color = Colors.Transparent
    ImageView4.Color = Colors.Transparent
    cnt = 1
    ImageView5.Color = Colors.Transparent
    ImageView5.Left = 40%x
'    ImageView5.top = Button1.Top + Button1.Height + 2%y
    ImageView5.top = 0%y
    ImageView5.Width = 20%x
    ImageView5.Height = ImageView5.Width
   

   
End Sub
Sub Button1_Click
   
'    ImageView1.Background = Null
   
    zx.isportrait = True
    zx.displayOrientation = 90     '90 is the default value that was set in the library. It works for most devices
                                   'although for eg the Nexus 5 will show an upside down preview with this setting.
                                   'I guess zx.displayOrientation = 270 will fix it for the Nexus 5 when used in portrait mode.
    zx.useFrontCam = False
    'set the timeoutDuration to a very high value (such as 2000000000) if you dont want it to time out
    '2000000000 = 63 years
    zx.timeoutDuration = 30
   
    'change these factors between 0 and 1 to change the size of the viewfinder rectangle
    'the library will limit the minimum size to 240 x 240 pixels and the maximum to (screen width) x (screen height) pixels

    zx.theViewFinderXfactor = 0.7      'portrait
    zx.theViewFinderYfactor = 0.5      'portrait
   
'    zx.theViewFinderXfactor = 0.5      'landscape
'    zx.theViewFinderYfactor = 0.5      'landscape
   
    zx.theFrameColor = Colors.Blue
    zx.theLaserColor = Colors.Yellow
   
    zx.moveLaser = True
   
    zx.theMaskColor = Colors.argb(100, 0, 0, 100)
    zx.theResultColor = Colors.Green
    zx.theResultPointColor = Colors.Red
   
    'set the prompt messages
    zx.theTopPromptMessage = "This was done......"
    zx.theTopPromptTextSize = 5%y                            'text size in pixels
    zx.topPromptColor = Colors.Green
    zx.topPromptDistanceFromTop = 1%y                        'pixel distance from top
    zx.textSkewnessTop = 0.0
   
   
    zx.theBottomPromptMessage = "Just for fun......"
    zx.theBottomPromptTextSize = 5%y                         'text size in pixels
    zx.bottomPromptColor = Colors.Green
    zx.bottomPromptDistanceFromBottom = 5%y                  'pixel distance from top
    zx.textSkewnessBottom = 0.0
   
    'add a bitmap - portrait
    zx.theBitMap = bm
    zx.theBitmapPosition(40%x,10%y,20%x,20%x)
   
    'add a bitmap - landscape
'    zx.theBitMap = bm
'    zx.theBitmapPosition(5%x,5%x,20%y,20%y)   

    zx.mustBeep = True
    zx.mustVibrate = True
   
    'START OF ADDED 7 NOVEMBER 2015:
'   Specify the bar code formats to scan
'   If not specified then all code formats will be scanned
'   Specify one of the following: PRODUCT_FORMATS, ONE_D_FORMATS, QR_CODE_FORMATS, DATA_MATRIX_FORMATS, AZTEC_FORMATS, PDF_417_FORMATS, TWO_D_FORMATS
'   PRODUCT_FORMATS are the following: UPC A, UPC E, EAN 13, EAN 8, RSS 14
'   ONE_D_FORMATS are all the PRODUCT FORMATS plus the following: CODE 39, CODE 93, CODE 128, ITF
'   TWO_D_FORMATS are the following: QR CODE, DATA MATRIX, AZTEC CODE, PDF 417

    'COMMENT THE BELOW LINE OR USE zx.ScanMode = "" to scan all the 1D and 2D type barcodes that this version of the ZXING library supports
    'zx.ScanMode = zx.FORMATS_TWO_D                
    'END OF ADDED 7 NOVEMBER 2015
    zx.scanInvertedCodes = False
   
    zx.BeginScan("myzx")   
   
End Sub

Sub myzx_result(atype As String, Value As String, image As Bitmap)
       
'    ImageView5.Bitmap = image
'    ImageView5.Gravity = Gravity.FILL
    If cnt = 1 Then
'      ImageView5.SetLayoutAnimated(3000,ImageView1.Left, ImageView1.Top,ImageView1.Width,ImageView1.Height)
'      Do While ((ImageView5.Left <> ImageView1.Left) AND (ImageView5.top <> ImageView1.top))
'      Log(ImageView5.Left)
'      Loop
      ImageView1.Bitmap = image
      ImageView1.Gravity = Gravity.FILL
     
      cnt = cnt + 1
'      ImageView5.Bitmap = Null
'      ImageView5.Left = 40%x
'      ImageView5.top = Button1.Top + Button1.Height + 2%y
'      ImageView5.Width = 20%x
'      ImageView5.Height = ImageView5.Width     
     
    Else If cnt = 2 Then
      ImageView2.Bitmap = image
      ImageView2.Gravity = Gravity.FILL
      cnt = cnt + 1
    Else If cnt = 3 Then
      ImageView3.Bitmap = image
      ImageView3.Gravity = Gravity.FILL
      cnt = cnt + 1
    Else If cnt = 4 Then
      ImageView4.Bitmap = image
      ImageView4.Gravity = Gravity.FILL
      cnt = cnt + 1
    Else If cnt > 4 Then
      ImageView1.Bitmap = Null
      ImageView1.Bitmap = ImageView2.Bitmap
      ImageView2.Bitmap = Null
      ImageView2.Bitmap = ImageView3.Bitmap
      ImageView3.Bitmap = Null
      ImageView3.Bitmap = ImageView4.Bitmap
      ImageView4.Bitmap = Null
      ImageView4.Bitmap = image
      ImageView1.Gravity = Gravity.FILL
      cnt = cnt + 1
    End If   

    Log(cnt)
   
    Log("type:" & atype &  " Value:" & Value)
    Msgbox(Value,"type:" & atype)
   
'    zx.BeginScan("myzx")   

End Sub
Sub myzx_timedout(timedOut As Boolean)
    Log("timedOut " & timedOut)

End Sub

Sub myzx_usercancelled(userCancelled As Boolean)
    Log("userCancelled " & userCancelled)
End Sub

Sub Activity_Resume


End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub
 

Attachments

  • JhsIceZxing1.xml
    13.5 KB · Views: 529
  • JhsIceZxing1.jar
    478 KB · Views: 561
  • b4aZxingMoveLaser.zip
    12 KB · Views: 556

hf

Member
Licensed User
This was requested via a PM. Ability to move the laser up/down while the scanner is active.

Attached new B4A lib files and a sample B4A project - copy the lib files (xml and jar) to your additional library folder.

Use the laser up/down like this:
B4X:
zx.moveLaser = True

Sample Code:
B4X:
#Region Module Attributes
    #FullScreen: False
    #IncludeTitle: True
    #ApplicationLabel: b4aZXING
    #VersionCode: 1
    #VersionName:
    #SupportedOrientations: portrait
    #CanInstallToExternalStorage: False
#End Region

'Activity module
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.
    Dim zx As JhsIceZxing1
    Private Button1 As Button
  
 
    Dim bm As Bitmap
 
    Dim ImageView1 As ImageView
    Private ImageView2 As ImageView
    Private ImageView3 As ImageView
    Private ImageView4 As ImageView
    Dim cnt As Int
    Private ImageView5 As ImageView

End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("main")
    bm.Initialize(File.DirAssets,"B4A.png")
    ImageView1.Color = Colors.Transparent
    ImageView2.Color = Colors.Transparent
    ImageView3.Color = Colors.Transparent
    ImageView4.Color = Colors.Transparent
    cnt = 1
    ImageView5.Color = Colors.Transparent
    ImageView5.Left = 40%x
'    ImageView5.top = Button1.Top + Button1.Height + 2%y
    ImageView5.top = 0%y
    ImageView5.Width = 20%x
    ImageView5.Height = ImageView5.Width
 

 
End Sub
Sub Button1_Click
 
'    ImageView1.Background = Null
 
    zx.isportrait = True
    zx.displayOrientation = 90     '90 is the default value that was set in the library. It works for most devices
                                   'although for eg the Nexus 5 will show an upside down preview with this setting.
                                   'I guess zx.displayOrientation = 270 will fix it for the Nexus 5 when used in portrait mode.
    zx.useFrontCam = False
    'set the timeoutDuration to a very high value (such as 2000000000) if you dont want it to time out
    '2000000000 = 63 years
    zx.timeoutDuration = 30
 
    'change these factors between 0 and 1 to change the size of the viewfinder rectangle
    'the library will limit the minimum size to 240 x 240 pixels and the maximum to (screen width) x (screen height) pixels

    zx.theViewFinderXfactor = 0.7      'portrait
    zx.theViewFinderYfactor = 0.5      'portrait
 
'    zx.theViewFinderXfactor = 0.5      'landscape
'    zx.theViewFinderYfactor = 0.5      'landscape
 
    zx.theFrameColor = Colors.Blue
    zx.theLaserColor = Colors.Yellow
 
    zx.moveLaser = True
 
    zx.theMaskColor = Colors.argb(100, 0, 0, 100)
    zx.theResultColor = Colors.Green
    zx.theResultPointColor = Colors.Red
 
    'set the prompt messages
    zx.theTopPromptMessage = "This was done......"
    zx.theTopPromptTextSize = 5%y                            'text size in pixels
    zx.topPromptColor = Colors.Green
    zx.topPromptDistanceFromTop = 1%y                        'pixel distance from top
    zx.textSkewnessTop = 0.0
 
 
    zx.theBottomPromptMessage = "Just for fun......"
    zx.theBottomPromptTextSize = 5%y                         'text size in pixels
    zx.bottomPromptColor = Colors.Green
    zx.bottomPromptDistanceFromBottom = 5%y                  'pixel distance from top
    zx.textSkewnessBottom = 0.0
 
    'add a bitmap - portrait
    zx.theBitMap = bm
    zx.theBitmapPosition(40%x,10%y,20%x,20%x)
 
    'add a bitmap - landscape
'    zx.theBitMap = bm
'    zx.theBitmapPosition(5%x,5%x,20%y,20%y) 

    zx.mustBeep = True
    zx.mustVibrate = True
 
    'START OF ADDED 7 NOVEMBER 2015:
'   Specify the bar code formats to scan
'   If not specified then all code formats will be scanned
'   Specify one of the following: PRODUCT_FORMATS, ONE_D_FORMATS, QR_CODE_FORMATS, DATA_MATRIX_FORMATS, AZTEC_FORMATS, PDF_417_FORMATS, TWO_D_FORMATS
'   PRODUCT_FORMATS are the following: UPC A, UPC E, EAN 13, EAN 8, RSS 14
'   ONE_D_FORMATS are all the PRODUCT FORMATS plus the following: CODE 39, CODE 93, CODE 128, ITF
'   TWO_D_FORMATS are the following: QR CODE, DATA MATRIX, AZTEC CODE, PDF 417

    'COMMENT THE BELOW LINE OR USE zx.ScanMode = "" to scan all the 1D and 2D type barcodes that this version of the ZXING library supports
    'zx.ScanMode = zx.FORMATS_TWO_D              
    'END OF ADDED 7 NOVEMBER 2015
    zx.scanInvertedCodes = False
 
    zx.BeginScan("myzx") 
 
End Sub

Sub myzx_result(atype As String, Value As String, image As Bitmap)
     
'    ImageView5.Bitmap = image
'    ImageView5.Gravity = Gravity.FILL
    If cnt = 1 Then
'      ImageView5.SetLayoutAnimated(3000,ImageView1.Left, ImageView1.Top,ImageView1.Width,ImageView1.Height)
'      Do While ((ImageView5.Left <> ImageView1.Left) AND (ImageView5.top <> ImageView1.top))
'      Log(ImageView5.Left)
'      Loop
      ImageView1.Bitmap = image
      ImageView1.Gravity = Gravity.FILL
   
      cnt = cnt + 1
'      ImageView5.Bitmap = Null
'      ImageView5.Left = 40%x
'      ImageView5.top = Button1.Top + Button1.Height + 2%y
'      ImageView5.Width = 20%x
'      ImageView5.Height = ImageView5.Width   
   
    Else If cnt = 2 Then
      ImageView2.Bitmap = image
      ImageView2.Gravity = Gravity.FILL
      cnt = cnt + 1
    Else If cnt = 3 Then
      ImageView3.Bitmap = image
      ImageView3.Gravity = Gravity.FILL
      cnt = cnt + 1
    Else If cnt = 4 Then
      ImageView4.Bitmap = image
      ImageView4.Gravity = Gravity.FILL
      cnt = cnt + 1
    Else If cnt > 4 Then
      ImageView1.Bitmap = Null
      ImageView1.Bitmap = ImageView2.Bitmap
      ImageView2.Bitmap = Null
      ImageView2.Bitmap = ImageView3.Bitmap
      ImageView3.Bitmap = Null
      ImageView3.Bitmap = ImageView4.Bitmap
      ImageView4.Bitmap = Null
      ImageView4.Bitmap = image
      ImageView1.Gravity = Gravity.FILL
      cnt = cnt + 1
    End If 

    Log(cnt)
 
    Log("type:" & atype &  " Value:" & Value)
    Msgbox(Value,"type:" & atype)
 
'    zx.BeginScan("myzx") 

End Sub
Sub myzx_timedout(timedOut As Boolean)
    Log("timedOut " & timedOut)

End Sub

Sub myzx_usercancelled(userCancelled As Boolean)
    Log("userCancelled " & userCancelled)
End Sub

Sub Activity_Resume


End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub




very good job,thanks a lot, but movelaser line shuld move top down botom on the square.
such as

img1-png.50892


2-png.57001
 
Last edited:

Johan Schoeman

Expert
Licensed User
Longtime User
very good job,thanks a lot, but movelaser line shuld move top down botom on the square.
such as

img1-png.50892


2-png.57001

We are obviously on two different projects. The images that you have posted above is not related to the library in this thread. Please post your questions and remarks in the applicable thread.
 

hf

Member
Licensed User
This was requested via a PM. Ability to move the laser up/down while the scanner is active.

Attached new B4A lib files and a sample B4A project - copy the lib files (xml and jar) to your additional library folder.

Use the laser up/down like this:
B4X:
zx.moveLaser = True

Sample Code:
B4X:
#Region Module Attributes
    #FullScreen: False
    #IncludeTitle: True
    #ApplicationLabel: b4aZXING
    #VersionCode: 1
    #VersionName:
    #SupportedOrientations: portrait
    #CanInstallToExternalStorage: False
#End Region

'Activity module
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.
    Dim zx As JhsIceZxing1
    Private Button1 As Button
   
  
    Dim bm As Bitmap
  
    Dim ImageView1 As ImageView
    Private ImageView2 As ImageView
    Private ImageView3 As ImageView
    Private ImageView4 As ImageView
    Dim cnt As Int
    Private ImageView5 As ImageView

End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("main")
    bm.Initialize(File.DirAssets,"B4A.png")
    ImageView1.Color = Colors.Transparent
    ImageView2.Color = Colors.Transparent
    ImageView3.Color = Colors.Transparent
    ImageView4.Color = Colors.Transparent
    cnt = 1
    ImageView5.Color = Colors.Transparent
    ImageView5.Left = 40%x
'    ImageView5.top = Button1.Top + Button1.Height + 2%y
    ImageView5.top = 0%y
    ImageView5.Width = 20%x
    ImageView5.Height = ImageView5.Width
  

  
End Sub
Sub Button1_Click
  
'    ImageView1.Background = Null
  
    zx.isportrait = True
    zx.displayOrientation = 90     '90 is the default value that was set in the library. It works for most devices
                                   'although for eg the Nexus 5 will show an upside down preview with this setting.
                                   'I guess zx.displayOrientation = 270 will fix it for the Nexus 5 when used in portrait mode.
    zx.useFrontCam = False
    'set the timeoutDuration to a very high value (such as 2000000000) if you dont want it to time out
    '2000000000 = 63 years
    zx.timeoutDuration = 30
  
    'change these factors between 0 and 1 to change the size of the viewfinder rectangle
    'the library will limit the minimum size to 240 x 240 pixels and the maximum to (screen width) x (screen height) pixels

    zx.theViewFinderXfactor = 0.7      'portrait
    zx.theViewFinderYfactor = 0.5      'portrait
  
'    zx.theViewFinderXfactor = 0.5      'landscape
'    zx.theViewFinderYfactor = 0.5      'landscape
  
    zx.theFrameColor = Colors.Blue
    zx.theLaserColor = Colors.Yellow
  
    zx.moveLaser = True
  
    zx.theMaskColor = Colors.argb(100, 0, 0, 100)
    zx.theResultColor = Colors.Green
    zx.theResultPointColor = Colors.Red
  
    'set the prompt messages
    zx.theTopPromptMessage = "This was done......"
    zx.theTopPromptTextSize = 5%y                            'text size in pixels
    zx.topPromptColor = Colors.Green
    zx.topPromptDistanceFromTop = 1%y                        'pixel distance from top
    zx.textSkewnessTop = 0.0
  
  
    zx.theBottomPromptMessage = "Just for fun......"
    zx.theBottomPromptTextSize = 5%y                         'text size in pixels
    zx.bottomPromptColor = Colors.Green
    zx.bottomPromptDistanceFromBottom = 5%y                  'pixel distance from top
    zx.textSkewnessBottom = 0.0
  
    'add a bitmap - portrait
    zx.theBitMap = bm
    zx.theBitmapPosition(40%x,10%y,20%x,20%x)
  
    'add a bitmap - landscape
'    zx.theBitMap = bm
'    zx.theBitmapPosition(5%x,5%x,20%y,20%y)  

    zx.mustBeep = True
    zx.mustVibrate = True
  
    'START OF ADDED 7 NOVEMBER 2015:
'   Specify the bar code formats to scan
'   If not specified then all code formats will be scanned
'   Specify one of the following: PRODUCT_FORMATS, ONE_D_FORMATS, QR_CODE_FORMATS, DATA_MATRIX_FORMATS, AZTEC_FORMATS, PDF_417_FORMATS, TWO_D_FORMATS
'   PRODUCT_FORMATS are the following: UPC A, UPC E, EAN 13, EAN 8, RSS 14
'   ONE_D_FORMATS are all the PRODUCT FORMATS plus the following: CODE 39, CODE 93, CODE 128, ITF
'   TWO_D_FORMATS are the following: QR CODE, DATA MATRIX, AZTEC CODE, PDF 417

    'COMMENT THE BELOW LINE OR USE zx.ScanMode = "" to scan all the 1D and 2D type barcodes that this version of the ZXING library supports
    'zx.ScanMode = zx.FORMATS_TWO_D               
    'END OF ADDED 7 NOVEMBER 2015
    zx.scanInvertedCodes = False
  
    zx.BeginScan("myzx")  
  
End Sub

Sub myzx_result(atype As String, Value As String, image As Bitmap)
      
'    ImageView5.Bitmap = image
'    ImageView5.Gravity = Gravity.FILL
    If cnt = 1 Then
'      ImageView5.SetLayoutAnimated(3000,ImageView1.Left, ImageView1.Top,ImageView1.Width,ImageView1.Height)
'      Do While ((ImageView5.Left <> ImageView1.Left) AND (ImageView5.top <> ImageView1.top))
'      Log(ImageView5.Left)
'      Loop
      ImageView1.Bitmap = image
      ImageView1.Gravity = Gravity.FILL
    
      cnt = cnt + 1
'      ImageView5.Bitmap = Null
'      ImageView5.Left = 40%x
'      ImageView5.top = Button1.Top + Button1.Height + 2%y
'      ImageView5.Width = 20%x
'      ImageView5.Height = ImageView5.Width    
    
    Else If cnt = 2 Then
      ImageView2.Bitmap = image
      ImageView2.Gravity = Gravity.FILL
      cnt = cnt + 1
    Else If cnt = 3 Then
      ImageView3.Bitmap = image
      ImageView3.Gravity = Gravity.FILL
      cnt = cnt + 1
    Else If cnt = 4 Then
      ImageView4.Bitmap = image
      ImageView4.Gravity = Gravity.FILL
      cnt = cnt + 1
    Else If cnt > 4 Then
      ImageView1.Bitmap = Null
      ImageView1.Bitmap = ImageView2.Bitmap
      ImageView2.Bitmap = Null
      ImageView2.Bitmap = ImageView3.Bitmap
      ImageView3.Bitmap = Null
      ImageView3.Bitmap = ImageView4.Bitmap
      ImageView4.Bitmap = Null
      ImageView4.Bitmap = image
      ImageView1.Gravity = Gravity.FILL
      cnt = cnt + 1
    End If  

    Log(cnt)
  
    Log("type:" & atype &  " Value:" & Value)
    Msgbox(Value,"type:" & atype)
  
'    zx.BeginScan("myzx")  

End Sub
Sub myzx_timedout(timedOut As Boolean)
    Log("timedOut " & timedOut)

End Sub

Sub myzx_usercancelled(userCancelled As Boolean)
    Log("userCancelled " & userCancelled)
End Sub

Sub Activity_Resume


End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


I modify the java code ,

B4X:
    zx.islasteruptodown=True
 

Attachments

  • JhsIceZxing1.jar
    478.3 KB · Views: 487
  • JhsIceZxing1.xml
    13.5 KB · Views: 474
  • b4aZxing.zip
    11.9 KB · Views: 536

Star-Dust

Expert
Licensed User
Longtime User
আপনি কি লিখেছেন? আপনি বুঝতে পারছেন না
 

MarcoRome

Expert
Licensed User
Longtime User
That's Chinese characters, and I want to get more attributes, custom scanning interfaces
I understood that they are Chinese characters ( obviously I do not know the meaning ) we are on the international forum and well they understand all.
Thank you
 

cxdzbl

Active Member
Licensed User
I understood that they are Chinese characters ( obviously I do not know the meaning ) we are on the international forum and well they understand all.
Thank you
I understood that they are Chinese characters ( obviously I do not know the meaning ) we are on the international forum and well they understand all.
Thank you
The library is very fast response in the scan, if can modify the Java code, custom scan interface is better.
 

MarcoRome

Expert
Licensed User
Longtime User
I know, Johan is the best "wrapper man" :):):) ( also in this community exist another great develop as Don, Informatix, etc ). Really great community...B4X will be the new language future...i'm sure
 

prajinpraveen

Active Member
Licensed User
Longtime User
On Android N, the code when ported to a new project, works only when the project name is set to "JHS.b4aZXING".
is there a workaround to this? Thank you
 

Johan Schoeman

Expert
Licensed User
Longtime User
On Android N, the code when ported to a new project, works only when the project name is set to "JHS.b4aZXING".
is there a workaround to this? Thank you
I have juts changed the package name to com.b4aZXINGabc (Project -> Build Configurations) on an Android 7.0 device and it works without a problem
 

prajinpraveen

Active Member
Licensed User
Longtime User
Thanks, it worked. the name was conflicting with a package name that was already installed. thanks for the prompt response
 

rraswisak

Active Member
Licensed User
Longtime User
Hi!
This library worked flawlessly on my phone previously, but now (i think after Android 6.0.1 update) it exits from the app immediately after scan. It doesn't fire xxx_result. I don't see any relation with the torch. I have a Note4, but it's also doesn't work on a fresh updated S7. I'm using it in portrait mode, if it counts.
Please help.
Thanks!

Hi Johan, thanks for sharing this great lib, i have same issue as @kokiky above.

I have 2 device with different functionality, first one is Zebra MC36 (Android 4.4) its a android base barcode reader and Infinix Note 4 (Android 7) as my daily personal phone. I have create my own app and been installed on both device. With MC36 the lib works well without a problem but not in Note 4.

The problem is, after scan the barcode the screen goes blank without returning a result, the app just freeze and i should end task the app.
I use the lib from post #83

Since i don't need landscape mode or torch functionality, my goals just read the barcode value and show it at textbox for further action.

Thanks
 

Johan Schoeman

Expert
Licensed User
Longtime User
Hi Johan, thanks for sharing this great lib, i have same issue as @kokiky above.

I have 2 device with different functionality, first one is Zebra MC36 (Android 4.4) its a android base barcode reader and Infinix Note 4 (Android 7) as my daily personal phone. I have create my own app and been installed on both device. With MC36 the lib works well without a problem but not in Note 4.

The problem is, after scan the barcode the screen goes blank without returning a result, the app just freeze and i should end task the app.
I use the lib from post #83

Since i don't need landscape mode or torch functionality, my goals just read the barcode value and show it at textbox for further action.

Thanks

Can you upload an extract of your own project so that I can test it on my Android 7 device? The project that I have posted is working on my Android 7 device
 
Top