#Region Project Attributes
#ApplicationLabel: QRCodeReaderView
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: portrait
#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 nativeMe As JavaObject
Dim rp As RuntimePermissions 'ADDED 8 June 2018
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 b1 As Button
Private b2 As Button
Private p1 As Panel
Private l1 As Label
Private oldString As String = ""
Private b3 As Button
' Private cb1 As CheckBox
Private qrcrv As QRCodeReaderV102
Private ImageView1 As ImageView
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")
nativeMe.InitializeContext
qrcrv.Visible = False
'Keep the order of the next 4 lines. CAMERA_BACK and CAMERA_FRONT will only contain correct values once qrcrv.BackFacingCamera and qrcrv.FrontFacingCamera has
'been executed else they will have default values of -1
Log(qrcrv.BackFacingCamera) 'see the popup help when entering this method - check if there is a back facing camera and return the ID of the camera
Log(qrcrv.FrontFacingCamera) 'see the popup help when entering this method - check if there is a front facing camera and retutn the ID of the camera
Log(qrcrv.CAMERA_BACK) 'see the popup help when entering this method
Log(qrcrv.CAMERA_FRONT) 'see the popup help when entering this method
'now you can use
qrcrv.CameraId = qrcrv.CAMERA_BACK 'or qrcrv.CameraId = qrcrv.CAMERA_FRONT
'qrcrv.CameraDegrees = 270 'set this to 0, 90, 180, 270
qrcrv.ScanNow = True
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub b1_Click
Dim Result As Boolean = True 'ADDED 8 June 2018
If Not(rp.Check(rp.PERMISSION_CAMERA)) Then 'ADDED 8 June 2018
rp.CheckAndRequest(rp.PERMISSION_CAMERA) 'ADDED 8 June 2018
Wait For Activity_PermissionResult (Permission As String, Result As Boolean) 'ADDED 8 June 2018
End If 'ADDED 8 June 2018
If Result Then
qrcrv.Visible = True
Sleep(0)
qrcrv.startScan
End If
End Sub
Sub b2_Click
qrcrv.stopScan
Sleep(0)
qrcrv.Visible = False
End Sub
Sub qrcrv_result_found(retval As String, img As Object)
If oldString <> retval Then
oldString = retval
Log("B4A: " & oldString)
l1.Text = oldString
Dim bm As Bitmap = img
ImageView1.Bitmap = bm
nativeMe.RunMethod("playTone", Null)
End If
End Sub
Sub b3_Click
If (qrcrv.isFlashOn = True) Then
qrcrv.setFlashOff
Else
qrcrv.setFlashOn
End If
End Sub
'Sub cb1_CheckedChange(Checked As Boolean)
'
' If cb1.Checked = True Then
' qrcrv.ScanNow = True
' Else
' qrcrv.ScanNow = False
' End If
'
'End Sub
#if Java
import android.media.ToneGenerator;
import android.media.AudioManager;
public void playTone() {
final ToneGenerator tg = new ToneGenerator(AudioManager.STREAM_NOTIFICATION, 100);
tg.startTone(ToneGenerator.TONE_PROP_BEEP);
}
#End If