Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What Happens To A Service When Device Goes Into Sleep

Im Developing a Service for android marshmallow which intend to keep running for a long period of time. My questions are"

What will happen to my service when the device goes into deep sleep?

Is there any way to control what happens when the system pauses the service to go to sleep ( like the onPause () method for activities)?

I have searched for an answer on Google unsuccessfully but if my question has already been answered I'm really sorry for wasting your time and would appreciate if you would point me towards the correct answer.

Thanks

like image 275
Talha Siddiqi Avatar asked Jan 28 '26 13:01

Talha Siddiqi


1 Answers

What will happen to my service when the device goes into deep sleep?

If your service is running, the device will not go into deep sleep. Deep sleep only happens if the CPU has literally nothing to do, which is not the case if your service is doing stuff.

Is there any way to control what happens when the system pauses the service to go to sleep

I don't fully understand that question. A service does not go to sleep. It is either running, or it's not. You control the lifecycle (apart from the OS killing the service's process when it needs to free up memory).

like image 192
Tim Avatar answered Jan 30 '26 04:01

Tim



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!