alarm update

Fox

Active Member
Licensed User
Longtime User
hey guys the solution that erel said is not really working for me. or im to bad :(. anyone have just an little example for simply alarm system.. just an input for hours after the time the phone get an alarm...
 

susu

Well-Known Member
Licensed User
Longtime User
I don't write Alarm app but I think the alarm system works like this:
1. Main activity get the alarm time. You calculate when the alarm will fire and schedule alarm service auto start at that moment.
2. When alarm service started, it re-schedule itself on next time (if got any).

Here some codes. Hope you find it useful.

* Main Activity

Sub GetNextTime(IntervalMinutes As Int) As Long
Dim t, interval As Long
interval = IntervalMinutes * DateTime.TicksPerMinute
t = DateTime.Now
t = t + interval
t = t - (t Mod interval)
Return t
End Sub

Sub SetAuto
StartServiceAt(autoalarm, GetNextTime(xxxx), True) ' Set alarm on next xxxx minute

noti.Initialize ' Set notification
noti.Light = False
noti.Vibrate = False
noti.OnGoingEvent = True
noti.Sound = False
noti.Icon = "icon"
noti.SetInfo("Auto Alarm", "On next" & xxxx & " minutes", "")
noti.Notify(1)
End Sub

* AutoAlarm service

Sub Service_Start
StartServiceAt("", DateTime.Now + (yyyy * 60 * 1000), True) ' Re-schedule to start itself on next yyyy minute
PlayAlarm
End Sub

Sub PlayAlarm
Mp.Load(File.DirAssets, "sound.wav")
Mp.Play
End Sub
 
Upvote 0
Top