#Region Service Attributes
#StartAtBoot: True
#ExcludeFromLibrary: 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 notif As Notification
Dim phoneId As PhoneId
Dim phoneEvents As PhoneEvents
Dim smsInterceptor As SmsInterceptor
Dim accelerometer As PhoneSensors
Dim gps As GPS
End Sub
Sub Service_Create
'This is the program entry point.
'This is a good place to load resources that are not specific to a single activity.
Starter_PhoneEvents_Init
Starter_SmsInterceptor_Init
Starter_Accelerometer_Init
Starter_Gps_Init
' Start running the service in foreground, in order not to be killed by Android OS
Starter_RunForeground
End Sub
Sub Service_Start (StartingIntent As Intent)
End Sub
Sub Service_TaskRemoved
'This event will be raised when the user removes the app from the recent apps list.
End Sub
'Return true to allow the OS default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
Return True
End Sub
Sub Service_Destroy
End Sub
'--------------------------------------------------------------------------
Sub Starter_PhoneEvents_Init
' Initialize PhoneEvents in order to be able to capure events
phoneEvents.InitializeWithPhoneState("PhoneEvents", phoneId)
End Sub
Sub Starter_SmsInterceptor_Init
smsInterceptor.Initialize("SmsInterceptor")
End Sub
Sub Starter_Accelerometer_Init
accelerometer.Initialize(accelerometer.TYPE_Accelerometer)
If accelerometer.StartListening("Accelerometer") = False Then
LogColor("Accelerometer sensor is not supported!", Colors.Red)
End If
End Sub
Sub Starter_Gps_Init
gps.Initialize ("GPS")
gps.Start(0, 0)
End Sub
Sub Starter_RunForeground
notif.Initialize
notif.Icon = "icon"
notif.SetInfo("Car Alarm", "Tap to access application", Main)
notif.Sound=False
notif.Vibrate=False
notif.Light=False
notif.OnGoingEvent=True
Service.StartForeground(1, notif)
End Sub
'----------------------------------------------------------------------------
' Events
'----------------------------------------------------------------------------
Sub PhoneEvents_BatteryChanged(Level As Int, Scale As Int, Plugged As Boolean, Intent As Intent)
' Pass information to BatteryMonitor module
modBatteryMonitor.Process(Level, Plugged)
End Sub
Sub PhoneEvents_PhoneStateChanged (State As String, IncomingNumber As String, Intent As Intent)
' Pass information to PhoneCallMonitor module
modPhoneCallMonitor.Process(State, IncomingNumber, Intent)
End Sub
Sub SmsInterceptor_MessageReceived (From As String, Body As String) As Boolean
' Pass information to SmsMonitor module
modSmsMonitor.Process(From, Body)
Return True
End Sub
Sub Accelerometer_SensorChanged (Values() As Float)
' Pass information to AccelerometerMonitor module
modAccelerometerMonitor.Process(Values)
End Sub
Sub GPS_LocationChanged (location As Location)
' Pass information to GpsMonitor module
modGpsMonitor.Process(location)
End Sub