#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.
Dim r2 As Reflector
Dim p As Phone
Dim TTS1 As TTS
Dim pevents As PhoneEvents
Dim dafare As Boolean
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 EditText1 As EditText
Dim EditText2 As EditText
Dim Button1 As Button
Dim Button2 As Button
Dim Button3 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("Layout1")
Activity.LoadLayout("main")
TTS1.Initialize("TTS1")
pevents.Initialize("pEvents")
dafare = True
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub pEvents_TextToSpeechFinish (Intent As Intent)
Dim tel As PhoneCalls
Dim telefonata As Intent
r2.Target = r2.GetContext
r2.Target = r2.RunMethod2("getSystemService", "audio", "java.lang.String")
r2.RunMethod2("setMode", 0, "java.lang.int")
If dafare = False Then
dafare = True
Return
End If
Sleep(5000)
telefonata = tel.Call(EditText1.Text)
StartActivity(telefonata)
End Sub
Sub Button1_Click
TTS1.SetLanguage(EditText2.Text,"")
'r2.Target = r2.GetContext
'r2.Target = r2.RunMethod2("getSystemService", "audio", "java.lang.String")
'r2.RunMethod2("setMode", 2, "java.lang.int")
TTS1.Speak("Hello. testing. 1. 2. 3. phone.", False)
End Sub
Sub Button2_Click
TTS1.SetLanguage(EditText2.Text,"")
r2.Target = r2.GetContext
r2.Target = r2.RunMethod2("getSystemService", "audio", "java.lang.String")
r2.RunMethod2("setMode", 2, "java.lang.int")
TTS1.Speak("Hello. testing. 1. 2. 3. phone.", False)
End Sub
Sub Button3_Click
dafare = False
TTS1.Stop
End Sub
Sub Sleep(ticks As Int)
Dim Lock1 As Lock
Dim milliseconds As Int
DoEvents
If ticks > 0 AND DateTime.TicksPerSecond > 0 Then
milliseconds = 1000 / DateTime.TicksPerSecond * ticks
Lock1.Initialize(True)
Lock1.WaitFor(milliseconds)
Lock1.Unlock
End If
End Sub