Android Question [Service Module] Device in sleep mode does not work!

Roberto P.

Well-Known Member
Licensed User
Longtime User
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.


Thanks so much
 

Attachments

  • TestService.zip
    13.2 KB · Views: 313

Roberto P.

Well-Known Member
Licensed User
Longtime User
Erel
I'm sorry, but have not been able to solve the problem!

can you give me more details or an example of "foreground service with a partial lock"

Thank you
 
Upvote 0

Roberto P.

Well-Known Member
Licensed User
Longtime User
Upvote 0

Roberto P.

Well-Known Member
Licensed User
Longtime User
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

thanks for help
 
Upvote 0

Roberto P.

Well-Known Member
Licensed User
Longtime User
I tried to use this code, but it crashes

B4X:
Sub Service_Create
   
 
    notif.Initialize
    notif.Sound             = False
    notif.Icon                 = "conferma_icon"
    notif.Vibrate         = False
    notif.AutoCancel     = True
   
    Service.StartForeground(1, notif)

.....
End Sub
 

Attachments

  • Immagine.png
    Immagine.png
    15.4 KB · Views: 309
Upvote 0
Top