Android Question Service Pause When ScreenLocked

cruzeiro991

Member
Licensed User
Longtime User
I have a service, this run all the time when user don't stop. But if user lock the screen, the service pause, i won't this happen. What i do to force service do not pause on screen locked?
 

KMatle

Expert
Licensed User
Longtime User
Usually a service is doing nothing until service functions are started from an Activity, Intent (f.e. new SMS received or new FCM message) or time scheduled (StartServiceAt). So it is not running all the time like the Activity is not running all the time even if it's visible (runing = doing things).

What does your service do? What do you expect?

Additionally: My Huawei stopps ALL services from my app due to energy saving settings. i had to permit it running in the background when screen is turned off.
 
Upvote 0

cruzeiro991

Member
Licensed User
Longtime User
My service starts with the system or when the user opens the app. Consider my service for example, it creates a loop of code through timer and is running the functions of my code normally (exchange wallpapers), I can see that it is working when the screen is locked. However when I lock the screen, it is noticed that the service is paused, because this only happens again when the screen is unlocked. From what I know a service does not have a sub pause, but when I lock the screen I know it is not destroyed because when I unlock it works again without having to open the app to start it again. I do not know what happens there in the meantime, what is it that makes the service pause?
 
Upvote 0

Tayfur

Well-Known Member
Licensed User
Longtime User
I have a service, this run all the time when user don't stop. But if user lock the screen, the service pause, i won't this happen. What i do to force service do not pause on screen locked?
Hello @cruzeiro991

I want to make sub in my app like your code.
i wan to , it has never stop a code (my code : listeninig UDP port, send recive some data other devices in lan)
Please share your code a service, this run all the time when user don't stop.
This best sample for my code.

if it possible, thank you for sharing
 
Upvote 0
Top