B4A Library ZXingLib(integration version)by icefairy333

integration version
zxing 2.1 inside
no need to install zx scaner or other apk,just a jar and xml file copy it to b4a library dir,and then use it well.

demo:
Code: Copy
'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 Zxing_B4A
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("Layout1")
zx.BeginScan("myzx")
End Sub
Sub myzx_result(atype As String,Values As String)
   Log("type:"&atype&"values:"&Values)
   Msgbox("type:"&atype&"values:"&Values,"result")
End Sub
Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub
and you must add last text to manifest editor:
Code: Copy
AddApplicationText(<activity android:name="ice.zxing.CaptureActivity"
         android:screenOrientation="landscape" android:configChanges="orientation|keyboardHidden"
         android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
         android:windowSoftInputMode="stateAlwaysHidden">
      </activity>)

lib doc:
b4aZXing
Author: IceFairy333
Version: 1.5
  • Zxing_B4A
    Events:
    • result (atype as String As , Values as String As )
    Fields:
    • isportrait As Boolean
    • useFrontCam As Boolean
    Methods:
    • BeginScan (EventName As String)
      please handle the event
      add this to manifest:<activity android:name="ice.zxing.CaptureActivity"
      android:screenOrientation="landscape" android:configChanges="orientation|keyboardHidden"
      android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
      android:windowSoftInputMode="stateAlwaysHidden"></activity>
    Permissions:
    • android.hardware.camera
    • android.hardware.camera.autofocus
    • android.permission.CAMERA
    • android.permission.FLASHLIGHT
    • android.permission.VIBRATE
    • android.permission.WRITE_EXTERNAL_STORAGE
lib doc:
b4aZXing
Author: IceFairy333
Version: 1.2
  • Zxing_B4A
    Events:
    • result (atype as String As , Values as String As )
    Methods:
    • BeginScan (EventName As String)
      please handle the event
      add this to manifest:<activity android:name="ice.zxing.CaptureActivity"
      android:screenOrientation="landscape" android:configChanges="orientation|keyboardHidden"
      android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
      android:windowSoftInputMode="stateAlwaysHidden"></activity>
    Permissions:
    • android.hardware.camera
    • android.hardware.camera.autofocus
    • android.permission.CAMERA
    • android.permission.FLASHLIGHT
    • android.permission.VIBRATE
    • android.permission.WRITE_EXTERNAL_STORAGE

anyone who has the scan twice,can download the library src to check it on your device,in my phone it works fine:signOops:

notice by Erel:The second scan happens because zx.BeginScan is called from Activity_Create. The activity is recreated when you change the orientation during the scanning.

The solution is simple. Move this call to a different sub (Button_Click for example).
 

Attachments

Last edited:
To icefairy333:
Do you possible add function "DecodeBitmap" in this library (without call activity)?
from Java example:
Code: Copy
Reader reader = new MultiFormatReader();
      try {

          Result result = reader.decode(bitmap);
          String contents = result.getText();
              byte[] rawBytes = result.getRawBytes();
              BarcodeFormat format = result.getBarcodeFormat();
              ResultPoint[] points = result.getResultPoints();

Very BIG THANKS for you support.
 
Hi,

is it possible to enable the flashlight of the camera?
Or maybe you could post the current sources of the library so i can take a look on it?

Thank you and regards.
 
Hi,

Have used B4AZxing to scan the barcode. It works perfectly when I try to scan all barcodes except for one set of barcodes where it just keeps trying to capture but doesnt actually capture. I just see the red line and yellow dots keep trying to focus. Any help/inputs is really appreciated.

Thanks
 
hi icefairy333 and thanks for this good job!

Just tested it on my Huawei Y301A1.
B4A interface is gone, which means I was no more inside B4A. and the scanning bar appeared normally.
but it is evident that the module is not integrated with B4A.
Rule: If the activity title disappears, and the scanner interface fills the whole screen, then you are no more
in B4A.
 
Could someone explain to me these "fields"?

Fields:
  • isportrait As Boolean
  • useFrontCam As Boolean

After the dot "on" the object I see only the BeginScan method.

Also, if I put "Portrait" in the manifest file, scan works, but having to turn the smartphone 90°
 
I did (download again)

upload_2014-1-28_6-21-12.png


Only BeginScan method, so what are the:

Fields:
  • isportrait As Boolean
  • useFrontCam As Boolean
?

My app uses the library ABZxing, but it forces the user to install this or QuickMark.

If b4aZXing worked in portrait mode, I would avoid this problem
 
I have just donated $50 to you. Thanks for your work.

On my phone, the test app shows a black screen and nothing else. No errors but the result sub is never fired.

This is an HTC One running Android 4.4.2 I will try a different device.
 
I tried it on a Galaxy S4 running Android 4.3 and it works just fine. The barcode window is a bit small so alignment is tricky but the result is correct. Thank you so much for your hard work on this. I hope others who use your libraries have been making donations too!
 
How do I get it to work in portrait mode? If I set "portrait" in the manifest, the scan window is rotated, and so is the picture so the barcodes are distorted.

Can this be fixed?
 
Hi Icefairy,

If I set the manifest to "portrait" and isportrait to TRUE then the screen looks OK. But codes that scan fine in landscape will not scan at all in portrait. Can you help?
 
I did (download again)

View attachment 22290

Only BeginScan method, so what are the:

Fields:
  • isportrait As Boolean
  • useFrontCam As Boolean
?

My app uses the library ABZxing, but it forces the user to install this or QuickMark.

If b4aZXing worked in portrait mode, I would avoid this problem
Your version is showing 1.2
 
Now I am sure to use the 1.5.

In the code I used IsPortrait = true
In the Manifest I tried using:
Android:screenOrientation = "portrait"
The scan looks like portrait, but the code is only returned by rotating the bar code to be scanned.

I also tried leaving "landscape" in the manifest and completely eliminating this attribute, but I have not solved.
 
Back
Top