ciginfo Well-Known Member Licensed User Longtime User Dec 18, 2011 #1 I rephrase my question differently. My application needs to send a notification every day at the same time. But it is the user of the application who must set the time of sending. I code In Main Module "HeureAverto" is a long which represents the time chosen by the user HTML: Copy Sub ChkNotif_CheckedChange(Checked As Boolean) If ChkNotif.Checked = True Then MyHeure = DateTime.Time(HeureAverto) StartServiceAt("Alarme",DateTime.TimeParse(MyHeure),True) End If End Sub In Module Service HTML: Copy Sub Service_Start (StartingIntent As Intent) Dim n As Notification n.Initialize n.Icon = "logo" n.SetInfo("Contraception", alerte, "Main") n.Vibrate = True n.Notify(1) StartServiceAt("", DateTime.Now + 60000 * 60 *24, True) '24 hours after End Sub The problem is: If the user chooses the time of notification for 12 h00 (HeureAverto) but if he makes the setting at 17 hours, the service starts every day at 17 hours and not at 12 hours as it should. This because, if this time chosen has already past the service will be started now. Do you understand me?
I rephrase my question differently. My application needs to send a notification every day at the same time. But it is the user of the application who must set the time of sending. I code In Main Module "HeureAverto" is a long which represents the time chosen by the user HTML: Copy Sub ChkNotif_CheckedChange(Checked As Boolean) If ChkNotif.Checked = True Then MyHeure = DateTime.Time(HeureAverto) StartServiceAt("Alarme",DateTime.TimeParse(MyHeure),True) End If End Sub In Module Service HTML: Copy Sub Service_Start (StartingIntent As Intent) Dim n As Notification n.Initialize n.Icon = "logo" n.SetInfo("Contraception", alerte, "Main") n.Vibrate = True n.Notify(1) StartServiceAt("", DateTime.Now + 60000 * 60 *24, True) '24 hours after End Sub The problem is: If the user chooses the time of notification for 12 h00 (HeureAverto) but if he makes the setting at 17 hours, the service starts every day at 17 hours and not at 12 hours as it should. This because, if this time chosen has already past the service will be started now. Do you understand me?
Erel B4X founder Staff member Licensed User Longtime User Dec 19, 2011 #2 The code here will help you calculate the target time: http://www.b4x.com/forum/basic4android-updates-questions/13297-alarm-using-timedialog.html#post75063 Upvote 0
The code here will help you calculate the target time: http://www.b4x.com/forum/basic4android-updates-questions/13297-alarm-using-timedialog.html#post75063