#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 Interval As Int: Interval=2 'om de 2 minuten
Dim n As Notification
Private Check As Bitmap
Dim lock As PhoneWakeState
Dim CheckTimer As Timer
Dim GPS1 As GPS
Dim LatLon As String
Dim Tracking As Boolean
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.
If(GPS1.IsInitialized=False) Then GPS1.Initialize("GPS")
Check = LoadBitmapResize(File.DirAssets, "check.png", 24dip, 24dip, False)
CheckTimer.Initialize("ItsTime", Interval*60000) '1000 Milliseconds = 1 second
Service.AutomaticForegroundMode=Service.AUTOMATIC_FOREGROUND_ALWAYS
lock.PartialLock
End Sub
Sub Service_Start (StartingIntent As Intent)
StartServiceAtExact(Me, DateTime.Now + 15 * DateTime.TicksPerMinute, True)
If(CheckTimer.Enabled=False) Then CheckTimer.Enabled = True
Track
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
Log("Destroyed")
If Tracking Then
GPS1.Stop
End If
Tracking = False
lock.ReleasePartialLock
End Sub
Public Sub Track
If Tracking Then Return
If Starter.rp.Check(Starter.rp.PERMISSION_ACCESS_FINE_LOCATION) = False Then
Log("No permission")
Return
Else
If(GPS1.GPSEnabled=True) Then
GPS1.Start(20000,5)
End If
End If
Tracking=True
End Sub
Sub ItsTime_Tick
Log("Gedaan: "&DateTime.Time(DateTime.Now))
If(EigenFuncties.Internet) Then OphalenMessages
End Sub
Sub DisplayIcon (Body As String) As Notification
Dim notif As NB6
notif.Initialize("default", Application.LabelName, "HIGH").SmallIcon(Check)
notif.SetDefaults(False,True,True)
notif.AutoCancel(True)
n.Initialize
n=notif.Build("TEST", Body, "tag", Fingerprint)
Return n
End Sub
Sub OphalenMessages
<< MY CODE >>
if (newmessage=true) then
DisplayIcon("New message...")
End If
End Sub
Sub GPS_LocationChanged (Location1 As Location)
LatLon=Location1.Latitude&"/"&Location1.Longitude
End Sub