question

gaurav avatar image
gaurav Suspended asked chanel Deactivated edited

TCP Socket in BG service is terminated when device enters sleep mode.

Hi All

I have created a background service in which I am using the tcp socket connection. When the app is live either in background/foreground, the connection is working as expected. But when the clover device goes to sleep, the service is stopped terminating the socket. I have used the WakeLock with PowerManager.PARTIAL_WAKE_LOCK and WifiLock to keep the CPU alive, but this also does not keep the cpu alive. It kills my service again.

Then I used the PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE flags so that my clover device be in DIM state and it works. This is not a correct approach to fix this as this always keep the clover screen ON.

Please let us know the suggested solution for that.
Clover Android SDKClover MiniClover Station
1 comment
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Bryanne Vega avatar image Bryanne Vega commented ·
Guaravdeep,

Any specific reason why your app should retain the TCP connection open?
0 Likes 0 ·

0 Answers

Welcome to the
Clover Developer Community