Android Question KeepAlive / PartialLock needed with B4XPages

Robert Valentino

Well-Known Member
Licensed User
Longtime User
I'm converting my music player app to B4XPages and was wondering since B4XPages programs don't get put to sleep do I still need to use KeepAlive or PartialLock
 

Peter Simpson

Expert
Licensed User
Longtime User
I'm converting my music player app to B4XPages and was wondering since B4XPages programs don't get put to sleep do I still need to use KeepAlive or PartialLock

Try it without them in B4XPages, if it stops it's a simple enough task to add them in. I've not found a reason to use them as my background tasks appears to run flawlessly using B4XPages, but some devices (Huawei or One+ for example) might need KeepAlive/PartialLock. But I cold be completely incorrect and adding them might be the way to go after you run your tests...
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
It depends. If you want the screen to stay on, even if there is no user interaction, then you should use PhoneWakeState.KeepAlive. A movie player for example needs to call it.

If you want to prevent the CPU from sleeping when the screen is off then call PartialLock. This is relevant for an app that needs to continue running in the background. You should do it together with a foreground service.
 
Upvote 0
Top