Android Question socket connection in a background service

Addo

Well-Known Member
Licensed User
Longtime User
Hi, I wonder is there any solution to keep a socket connection alive when the phone sleep or in the background for a long time?
the current situation is when a user puts the phone to sleep or put the app in the background for a while the service keeps running but the socket connection gets disconnected. I tried everything to avoid this behavior starting from sending a message periodically within a timer inside the service to keep the socket running.
and I have set the power manager as following
but that won't change anything. any way to avoid the socket disconnection when the phone in the background?
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…