#Region Project Attributes
#ApplicationLabel: b4NewQRCodeReaderView
#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
Private rp As RuntimePermissions
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 nqrcrv As NewQRCodeReaderView
Private Button1 As Button
Private torchOn As Boolean = False
Private Button2 As Button
Private Button3 As Button
Private prevscan As String = ""
' Private Label1 As Label
Private CheckBox1 As CheckBox
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
' nqrcrv.Initialize("nqrcrv")
' Button1.Initialize("Button1")
' Button2.Initialize("Button2")
' Button3.Initialize("Button3")
' CheckBox1.Initialize("CheckBox1")
'
'
' Activity.AddView(nqrcrv, 0%x, 0%y, 100%x, 100%x)
' Activity.AddView(Button2, 2%x, 100%x + 2%y, 31%x, 15%y)
' Activity.AddView(Button1, 35%x, 100%x + 2%y, 35%x, 15%y)
' Activity.AddView(Button3, 72%x, 100%x + 2%y, 31%x, 15%y)
' Activity.AddView(CheckBox1, 2%x, 100%y - 10%y, 15%x, 10%y)
'
' Button1.Color = Colors.Green
' Button1.Text = "Torch"
' Button1.TextColor = Colors.Black
' Button1.TextSize = 15
' Button1.Typeface = Typeface.DEFAULT_BOLD
'
' Button2.Color = Colors.Yellow
' Button2.Text = "Start Scan"
' Button2.TextColor = Colors.Black
' Button2.TextSize = 15
' Button2.Typeface = Typeface.DEFAULT_BOLD
'
' Button3.Color = Colors.Cyan
' Button3.Text = "Stop Scan"
' Button3.TextColor = Colors.Black
' Button3.TextSize = 15
' Button3.Typeface = Typeface.DEFAULT_BOLD
nqrcrv.QRDecodingEnabled = True
nqrcrv.AutofocusInterval = 500
nqrcrv.ScanNow = False
nqrcrv.Visible = False
nqrcrv.ResultPointColor = Colors.Magenta
nqrcrv.ResultPointSize = 25
CheckBox1.Checked = False
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
torchOn = False
CheckBox1.Checked = False
nqrcrv.stopCamera
prevscan = ""
End Sub
Sub nqrcrv_result_found(retval As String, obj As Object)
Dim bm As Bitmap = obj
If prevscan = retval Then
'Log("same scan")
prevscan = retval
Else
Log("b4aResult = " & retval)
prevscan = retval
ImageView1.Bitmap = bm
' nativeMe.RunMethod("playTone", Null)
End If
End Sub
Sub Button1_Click
If nqrcrv.Visible = True Then
If torchOn = False Then
nqrcrv.TorchEnabled = True
torchOn = True
Else
nqrcrv.TorchEnabled = False
torchOn = False
End If
End If
End Sub
Sub Button2_Click
Dim Result As Boolean = True
If Not(rp.Check(rp.PERMISSION_CAMERA)) Then
rp.CheckAndRequest(rp.PERMISSION_CAMERA)
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
End If
If Result Then
nqrcrv.Visible = True
nqrcrv.setBackCamera
nqrcrv.startCamera
End If
End Sub
Sub Button3_Click
nqrcrv.Visible = False
CheckBox1.Checked = False
nqrcrv.stopCamera
prevscan = ""
End Sub
Sub CheckBox1_CheckedChange(Checked As Boolean)
If Checked = True Then
nqrcrv.ScanNow = True
Else
nqrcrv.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