HI All,
I cannot run a service when the device goes in sleep mode. I tried to use the forum recommendations, including StartServiceAt, but does not work!
Can anyone help me understand how to always run the service: off application and device in sleep.
I attach small project.
I specify that I have included two services just to make trials.
2. If you have a long running task and you don't want the OS to kill your process when there is no visible activity then you should call Service.StartForeground. Android will treat your application as if it is a visible application and will not kill it.
Hi to all,
finally, using PhoneWakeState it is unable to prevent the device to go to sleep and active services are able to maintain active communication or jobs
It may be useful here are the steps I followed:
B4X:
1- add the following permission in AddPermission (android.permission.WAKE_LOCK) files in the manifest editor
2- add member in
Sub Process_Globals
Dim pws As PhoneWakeState
end sub
3 - call function
sub Service_Start
pws.PartialLock
end sub
4
Sub-Service_Destroy
pws.ReleasePartialLock
end sub