I wanted to monitor the battery level through out the day by simply having a service announce verbally the level as it changed. Does the Text to Speech engine stay initialized all by itself or should I check its state every time I want it to speak?
Code for Service follows:
Code for Service follows:
B4X:
Sub Process_Globals
Dim PE As PhoneEvents
Dim TTS1 As TTS
Dim OldValue As Int
End Sub
Sub Service_Create
TTS1.Initialize("TTS1")
End Sub
Sub PE_BatteryChanged (Level As Int, Scale As Int, Plugged As Boolean, Intent As Intent)
If OldValue <> Level Then
TTS1.Speak(Level,True)
End If
OldValue = Level
End Sub
Sub TTS1_Ready (Success As Boolean)
PE.Initialize("PE")
End Sub