#Region Module Attributes
#StartAtBoot: False
#End Region
'Service module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim MP As MediaPlayer
Dim DT As Int
Dim N As Notification
End Sub
Sub Service_Create
MP.Initialize()
MP.Load(File.DirAssets,"bell10s.ogg")
DT = Main.DulationV
If DT = 0 Then
DT = 120
Log( "Main.DulationV = 0 again")
End If
n.Initialize
n.Icon = "icon"
n.Sound = False
n.Vibrate= False
n.Light=False
n.OnGoingEvent=True
n.SetInfo("Mindfulness Bell", "Interval= " & Main.TextV &" First=" & DateTime.Time(DateTime.now) , Main)
Log("First Start = " & DateTime.Time(DateTime.now))
n.Notify(1)
End Sub
Sub Service_Start (StartingIntent As Intent)
MP.Play
n.SetInfo("Mindfulness Bell", "Interval= " & Main.TextV &" Last=" & DateTime.Time(DateTime.now) , Main)
Log(DateTime.Time(DateTime.now))
n.Notify(1)
Log("DT = "& DT)
Log("DulationV = "& Main.DulationV)
If DT > 110 Then
StartServiceAt("",DateTime.Now+DT*DateTime.TicksPerSecond,True)
Else
Log(" DT error = "&DT)
Service_Destroy
End If
End Sub
Sub Service_Destroy
CancelScheduledService("")
StopService("")
n.Cancel(1)
End Sub