This is a wrapper for this Github project. It is similar to @DonManfred 's posting here in the sense that it also makes use of the Google Mobile Vision API. @DonManfred 's version is however far more advanced. For me this was a learning exercise and I will therefore try and explain in detail how you should go about to set this up:
1. You will need the following libraries in your additional library folder (recent versions):
3. Download and extract resource.zip. The folder in this zip file should be copied to the B4A project so that it is on the same folder level as the /Files and /Objects folders of the B4A project.
4. Download and extract QREaderLibFiles.zip and copy the jar and xml to your additional library folder
5. Download and extract resourceAdditionalLibs.zip. It contains a folder that is also named resource. Copy this folder into your additional library folder
6. Set up the correct paths in the B4A project to the following:
Compile the B4A project and you should get this:
The library raises an event in the B4A project and passes on the decoded string to the B4A project (i.e the "message" in the barcode).
I am also posting the Java code for whoever would like to build on the project. in order to compile the Java code you need to create a libs folder on the same folder level as the src folder and copy the 3 jar files mentioned in (1) above to this folder.
Sample code:
Library as it stands at present:
QREader
Author: Github: Nishant Srivastava, Wrapped by: Johan Schoeman
Version: 1
You should also take note of the B4A Manifest should you start a new project.
1. You will need the following libraries in your additional library folder (recent versions):
android-support-v4.jar
android-support-v7-appcompat.jar
google-play-services.jar
2. Download and extract b4AQREader.zip (it is the B4A project)android-support-v7-appcompat.jar
google-play-services.jar
3. Download and extract resource.zip. The folder in this zip file should be copied to the B4A project so that it is on the same folder level as the /Files and /Objects folders of the B4A project.
4. Download and extract QREaderLibFiles.zip and copy the jar and xml to your additional library folder
5. Download and extract resourceAdditionalLibs.zip. It contains a folder that is also named resource. Copy this folder into your additional library folder
6. Set up the correct paths in the B4A project to the following:
B4X:
#AdditionalRes: C:\Users\----------2\Documents\Basic 4 Android\JOHAN APPS\JHS LIBS\resource\b4a_appcompat, de.amberhome.objects.appcompat
#AdditionalRes: C:\ANDRIOD_SDK_TOOLS\extras\android\support\v7\appcompat\res, android.support.v7.appcompat
#AdditionalRes: C:\ANDRIOD_SDK_TOOLS\extras\google\google_play_services\libproject\google-play-services_lib\res, com.google.android.gms
Compile the B4A project and you should get this:
The library raises an event in the B4A project and passes on the decoded string to the B4A project (i.e the "message" in the barcode).
I am also posting the Java code for whoever would like to build on the project. in order to compile the Java code you need to create a libs folder on the same folder level as the src folder and copy the 3 jar files mentioned in (1) above to this folder.
Sample code:
B4X:
#Region Project Attributes
#ApplicationLabel: QREader
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#AdditionalRes: ..\resource
#AdditionalRes: C:\Users\----------2\Documents\Basic 4 Android\JOHAN APPS\JHS LIBS\resource\b4a_appcompat, de.amberhome.objects.appcompat
#AdditionalRes: C:\ANDRIOD_SDK_TOOLS\extras\android\support\v7\appcompat\res, android.support.v7.appcompat
#AdditionalRes: C:\ANDRIOD_SDK_TOOLS\extras\google\google_play_services\libproject\google-play-services_lib\res, com.google.android.gms
#ExcludeClasses: .games, .drive, .ads, .fitness, .wearable, .measurement, .cast, .auth, .nearby
#ExcludeClasses: .tagmanager, .analytics, .wallet, .plus, .gcm, .maps, .panorama
'#Extends: android.support.v7.app.ActionBarActivity
#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.
Dim myscanner As QREader
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("myscanner")
myscanner.InitialScannerText = "Scan a 1D or 2D Barcode"
End Sub
Sub Activity_Resume
myscanner.StartScan
End Sub
Sub Activity_Pause (UserClosed As Boolean)
myscanner.StopScan
End Sub
Sub myscanner_scan_result(result As String)
Log("result = " & result)
End Sub
Library as it stands at present:
QREader
Author: Github: Nishant Srivastava, Wrapped by: Johan Schoeman
Version: 1
Fields:- camera_view As Int
- code_info As Int
Fields:- activity_main As Int
- QREader
Events:- scan_result (result As String)
- Initialize (paramString As String)
- IsInitialized As Boolean
- StartScan
- StopScan
- InitialScannerText As String [write only]
You should also take note of the B4A Manifest should you start a new project.
Attachments
Last edited: