Android Question Daily alarms on different times scheduled on database

jkhazraji

Active Member
Licensed User
Longtime User
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:
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
Any help please?
 

Attachments

  • 3Alarms.zip
    114 KB · Views: 422
Last edited:

jkhazraji

Active Member
Licensed User
Longtime User
Great..but what if I want three different times for each day over a period of one week e.g..(3.0,3.25,19) for 03/02/2017 and (3.05,3.30,19.25) for the next day ...etc??
 
Upvote 0

Genil

New Member
I tried to run this program but ERROR occured

An Error has occured in sub:main_activity_resume(javaline:396)
java.lang.RuntimeExceptopn: Objcet should first be initialized(Label).
Continue?



What is this ERROR ?? Can u please give an answer regarding to this ?
 
Upvote 0

ronell

Well-Known Member
Licensed User
Longtime User
I tried to run this program but ERROR occured

An Error has occured in sub:main_activity_resume(javaline:396)
java.lang.RuntimeExceptopn: Objcet should first be initialized(Label).
Continue?



What is this ERROR ?? Can u please give an answer regarding to this ?

is the label added in designer? if not then u should initialized it first

B4X:
label1.initialize("label")
 
Upvote 0

jkhazraji

Active Member
Licensed User
Longtime User
It is already in the designer..check it..
 
Upvote 0
Top