#Region Project Attributes
#ApplicationLabel: B4A Example
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#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.
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 PrevIntent As Intent
Private vr As VoiceRecognition
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("1")
vr.Initialize("vr")
End Sub
Sub Activity_Resume
Dim wIn As Intent
wIn = Activity.GetStartingIntent
If wIn.Action = "android.intent.action.ASSIST" Or wIn.Action = "android.intent.action.VOICE_COMMAND" Then
vr.Listen
End If
PrevIntent = Activity.GetStartingIntent
End Sub
Sub Activity_Pause (UserClosed As Boolean)
StopBluetoothSco
End Sub
Sub StopBluetoothSco()
Dim r As Reflector
ToastMessageShow("Stop sco", False)
r.Target = r.GetContext
r.Target = r.RunMethod2("getSystemService", "audio", "java.lang.String")
r.RunMethod("stopBluetoothSco")
End Sub
Sub StartBluetoothSco()
Dim r As Reflector
ToastMessageShow("Start sco", False)
r.Target = r.GetContext
r.Target = r.RunMethod2("getSystemService", "audio", "java.lang.String")
r.RunMethod("startBluetoothSco")
End Sub