Hello to all,
one year ago I developed an app that RINGER_SILENT the phone.
The app test the hour (it need to silence the phone at 10:30, 15:00, 18:30 and 22:00) only if it is connected to know wifi (Agenzia2000 and Vodafone_SirJo).
Well, the program works very very well from one year ago (on Android 4.x), but now I have installed this program on Android 6.x, it works well but StartServiceAt some times don't start exactly at the need hour.
In my app, each time that the Service_Start is executed, it calculate the next event and call StartServiceAt with this time and I write it into a log file.
Ok, my log file is:
As you see (for example)
26/07/2017 15:00:00 Next event: 26/07/2017 18:30:00
but Service_Start will call at 18:32:24
Is there a system for to call Service_Start more accurate ??
My main source is:
Many thanks
Sergio
P.S.: I use B4A 4.0
one year ago I developed an app that RINGER_SILENT the phone.
The app test the hour (it need to silence the phone at 10:30, 15:00, 18:30 and 22:00) only if it is connected to know wifi (Agenzia2000 and Vodafone_SirJo).
Well, the program works very very well from one year ago (on Android 4.x), but now I have installed this program on Android 6.x, it works well but StartServiceAt some times don't start exactly at the need hour.
In my app, each time that the Service_Start is executed, it calculate the next event and call StartServiceAt with this time and I write it into a log file.
Ok, my log file is:
B4X:
26/07/2017 00:07:23 Service_Start
26/07/2017 00:07:23 Nothing to do
26/07/2017 00:07:23 Next event: 26/07/2017 10:30:00
26/07/2017 00:07:23 ---------------------------------------------
26/07/2017 10:30:11 Service_Start
26/07/2017 10:30:11 isWifiConnected = true
26/07/2017 10:30:12 SSID = Agenzia2000
26/07/2017 10:30:12 RINGER_SILENT
26/07/2017 10:30:12 Next event: 26/07/2017 15:00:00
26/07/2017 10:30:12 ---------------------------------------------
26/07/2017 15:00:00 Service_Start
26/07/2017 15:00:00 isWifiConnected = true
26/07/2017 15:00:00 SSID = Agenzia2000
26/07/2017 15:00:00 RINGER_SILENT
26/07/2017 15:00:00 Next event: 26/07/2017 18:30:00
26/07/2017 15:00:00 ---------------------------------------------
26/07/2017 18:32:24 Service_Start
26/07/2017 18:32:24 isWifiConnected = true
26/07/2017 18:32:24 SSID = Agenzia2000
26/07/2017 18:32:24 RINGER_SILENT
26/07/2017 18:32:24 Next event: 26/07/2017 22:00:00
26/07/2017 18:32:24 ---------------------------------------------
26/07/2017 22:02:29 Service_Start
26/07/2017 22:02:29 isWifiConnected = true
26/07/2017 22:02:29 SSID = Vodafone_SirJo
26/07/2017 22:02:29 RINGER_SILENT
26/07/2017 22:02:29 Next event: 27/07/2017 10:30:00
26/07/2017 22:02:29 ---------------------------------------------
As you see (for example)
26/07/2017 15:00:00 Next event: 26/07/2017 18:30:00
but Service_Start will call at 18:32:24
Is there a system for to call Service_Start more accurate ??
My main source is:
B4X:
Sub Service_Start(StartingIntent As Intent)
.......... make all I need to do
' calculate next event
Dim n As Long = ..... calculate date and time of next event
DateTime.DateFormat = "dd/MM/yyyy"
DateTime.TimeFormat = "HH:mm:ss"
' write it on a log file so I can to see if it is correct
LogWrite("Next event: " & DateTime.Date(n) & " " & DateTime.Time(n))
LogWrite("---------------------------------------------")
StartServiceAt("", n, True)
End Sub
Many thanks
Sergio
P.S.: I use B4A 4.0