I tried to write a little alarm app by using service module.
Main activity code:
Service module name "notischedule" code:
Compile ok but it doesn't work and there's no notification icon. What did I miss? Please help.
Main activity code:
B4X:
Sub SetSchedule_ItemClick (Position As Int, Value As Object)
Dim start, now, atTime As Long
DateTime.TimeFormat = "HH:mm"
start = DateTime.TimeParse(Value) ' parse time from xml, format like 14:32
now = DateTime.Now
If start > now Then
atTime = start - now
Msgbox("It's OK", "Set schedule")
StartServiceAt(notischedule, atTime, False)
Else
Msgbox("Cannot set schedule in past time","Error")
End If
End Sub
Service module name "notischedule" code:
B4X:
Sub Process_Globals
Dim Noti As Notification
End Sub
Sub Service_Create
Noti.Initialize
Noti.Icon = "icon"
Noti.Light = True
Noti.Sound = True
Noti.Vibrate = True
Noti.AutoCancel = True
End Sub
Sub Service_Start
Noti.SetInfo("Hey, it's time now!", "Alarm", Main)
Noti.Notify(1)
End Sub
Compile ok but it doesn't work and there's no notification icon. What did I miss? Please help.