#Region Project Attributes
#ApplicationLabel: b4aCodeScanner
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: portrait
#CanInstallToExternalStorage: False
#End Region
#AdditionalRes: ..\LibRes
#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.
Private cs1 As CodeScanner
Private csv1 As CodeScannerView
Private Button1 As Button
Private Button2 As Button
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")
csv1.AutoFocusButtonColor = Colors.Red
csv1.AutoFocusButtonVisible = True
csv1.AutoFocusEnabled = True
csv1.FlashButtonColor = Colors.Green
csv1.FlashButtonVisible = True
csv1.FlashEnabled = True
csv1.FrameColor = Colors.Blue
csv1.FrameCornersSize = 200
csv1.FrameThickness = 15
csv1.MaskColor = Colors.ARGB(100, 200, 0, 0)
cs1.Initialize("codescan", csv1) 'initialize CodeScanner with the CodeScannerView
cs1.autoFocus = True 'set autofocus to be true/false
cs1.autoFocusInterval = 1500 'set the autofocus interval (milliseconds)
cs1.autoFocusMode = cs1.FOCUS_MODE_SAFE 'or cs1.FOCUS_MODE_CONTINUOUS
cs1.CameraToUse = cs1.CAMERA_BACK 'or cs1.CAMERA_FRONT
cs1.flash = False 'start or don't start the flash when the scanner starts
cs1.formats = cs1.FORMATS_ALL 'or cs1.FORMATS_1D or cs1.FORMATS_2D
cs1.ScanMode = cs1.SCAN_MODE_CONTINUOUS 'or cs1.SCAN_MODE_SINGLE
'THIS MUST BE THE LAST CALL ONCE ALL OF THE ABOVE HAVE BEEN SET
cs1.build
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
cs1.stopScan
End Sub
Sub Button1_Click
cs1.startScan
End Sub
Sub Button2_Click
cs1.stopScan
End Sub
Sub codescan_scan_result(rst As String)
Log("B4A Result = " & rst)
End Sub