Edit: V1.34 is available.
This version adds two new events: ConnectivityChanged and TextToSpeechFinish. This version also adds a new object named SmsInterceptor that handles new incoming Sms messages.
A simple example that prints the events to the LogCat:
Main activity
S1 service
Installation instructions: Unzip the attached file and copy both files to the internal libraries folder. The default is: C:\Program Files\Anywhere Software\Basic4android\Libraries
This version adds two new events: ConnectivityChanged and TextToSpeechFinish. This version also adds a new object named SmsInterceptor that handles new incoming Sms messages.
A simple example that prints the events to the LogCat:
Main activity
B4X:
Sub Process_Globals
Dim TTS As TTS
End Sub
Sub Globals
End Sub
Sub Activity_Create(FirstTime As Boolean)
StartService(S1)
TTS.Initialize("tts")
End Sub
Sub TTS_Ready (Success As Boolean)
If Success Then TTS.Speak("hello world", False)
End Sub
B4X:
'Service module
Sub Process_Globals
Dim PE As PhoneEvents
Dim SI As SMSInterceptor
End Sub
Sub Service_Create
PE.Initialize("PE")
SI.Initialize("SI")
End Sub
Sub Service_Start
End Sub
Sub SI_MessageReceived (From As String, Body As String)
Log("MessageReceived: From = " & From & ", Body = " & Body)
End Sub
Sub PE_TextToSpeechFinish (Intent As Intent)
Log("TextToSpeechFinish")
End Sub
Sub PE_ConnectivityChanged (NetworkType As String, State As String, Intent As Intent)
Log("ConnectivityChanged: " & NetworkType & ", state = " & State)
Log(Intent.ExtrasToString)
End Sub
Sub PE_AirplaneModeChanged (State As Boolean, Intent As Intent)
Log("AirplaneModeChanged: "& state)
Log(Intent.ExtrasToString)
End Sub
Sub PE_BatteryChanged (Level As Int, Scale As Int, Plugged As Boolean, Intent As Intent)
Log("BatteryChanged: Level = " & level & ", Scale = " & scale & ", Plugged = " & Plugged)
End Sub
Sub PE_CameraButtonPressed (Intent As Intent)
Log("CameraButtonPressed")
Log(Intent.ExtrasToString)
End Sub
Sub PE_PackageRemoved (Package As String, Intent As Intent)
Log("PackageRemoved: " & Package)
Log(Intent.ExtrasToString)
End Sub
Sub PE_PackageAdded (Package As String, Intent As Intent)
Log("PackageAdded: " & Package)
Log(intent.ExtrasToString)
End Sub
Sub PE_ScreenOff (Intent As Intent)
Log("ScreenOff")
End Sub
Sub PE_ScreenOn (Intent As Intent)
Log("ScreenOn")
End Sub
Sub PE_Shutdown (Intent As Intent)
Log("Shutdown")
End Sub
Sub PE_UserPresent (Intent As Intent)
Log("UserPresent")
End Sub
Sub PE_PhoneStateChanged (State As String, IncomingNumber As String, Intent As Intent)
Log("PhoneStateChanged, State = " & State & ", IncomingNumber = " & IncomingNumber)
Log(Intent.ExtrasToString)
End Sub
Sub Service_Destroy
End Sub