StartServiceAt & notification

ciginfo

Well-Known Member
Licensed User
Longtime User
Hello, thank you for helping me
I return to my problem I can not use StarService and startserviceat.
My application needs to send a notification every evening at 20 hours but the data is different every day.
I created a ModuleService "MyModuleService". In Process_Global are the variables. Then a routine "A_FAIRE" that creates the notification to be sent depending on several parameters. In Sub Service_Start I code:
A_FAIRE
B4X:
Dim n as Notification
n.Initialize
n.Icon = "logo"
n.SetInfo ("MyService" MyMessage, "Main")
n.Vibrate = True
n.Notify (1)
'Here I do not know what to write
StartServiceAt ("" + DateTime.Now DateTime.TimeParse (???????????), True)

'In Main module 
sub BtnValide_Click
StartService (MonModuleService)
End Sub
questions
1) When I click on BtnValide, notification is sent immediately but i want sent in the evening.
2) In ServiceCreate, what should I put
3) Where and how to code for the notification to be sent regularly the day and hour that I want.
 
Last edited by a moderator:

bergapappa

Member
Licensed User
Longtime User
Hi

I guess the notification i sent right away because you just start the service.
Instead of StartService you should put the StartServiceAt there instead.
Ex.
If you want to start your service 10 sec after the button is clicked it should look something like this

Sub BtnValide_Click
StartServiceAt("MonModuleService", DateTime.Now + 10000, True)
End Sub

And if you want it to go again after a while, I usually put another StartServiceAt after my "action" in the service module.
Remember that if you do this it will be like a loop that will go on until you kill it.
To cancel as scheduled service start you use CancelScheduledService("MonModuleService")

I'm a novice, but have just gone through almost the same thing :)
 
Last edited:
Upvote 0

bergapappa

Member
Licensed User
Longtime User
ServiceCreate is for instance for initializing stuff like a mediaplayer, but probably for more.
It is not sure you need to put anything there, depends on what you have in the app.
But I'm no expert, you should read the service module tutorial.
 
Upvote 0
Top