I am trying to make B4a program that functions to sound 3 alarms on different times of the day along a period of one month using a database file to set the time for each alarm. But as I ran the program, it entered into an indefinite loop of making successive sounds of alarms. The whole code is attached..
The code of service is as follows:
Any help please?
The code of service is as follows:
B4X:
Sub Service_Start(StartingIntent As Intent)
Dim StartPos As Int=0
Dim AlarmTimeFound As Boolean
For StartPos=0 To Main.curs.RowCount-2
Main.curs.Position=Main.curs.Position+ StartPos
If Main.curs.GetString("DayDate")=DateTime.Date(DateTime.Now) And Main.curs.GetString("MTime" & ":00") Then
Main.NextReminder=DateTime.DateTimeParse(Main.curs.GetString("DayDate"),Main.curs.GetString("MTime") & ":00")
AlarmTimeFound=True
Exit
Else
AlarmTimeFound=False
End If
Next
If AlarmTimeFound=True Then
mp.Initialize2("mplay")
timer1.Initialize("timer1",300)
timer1.Enabled=True
mp.Load(File.DirAssets,"Marimba-logo.mp3")
ToastMessageShow("Woken up " & DateUtils.TicksToString( Main.NextReminder) & ":" & Main.AlCount,True)
mp.Play
n1.Notify(1)
Log(" :Alarm1" & DateUtils.TicksToString( Main.NextReminder))
StopService("")
CancelScheduledService("")
StartServiceAt("", Main.NextReminder,True)
End If
End Sub
Attachments
Last edited: