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?
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
how to set power manager wake lock with the following rules
in java, I can set the power manager to keep a socket connection alive like following PowerManager.WakeLock newWakeLock = ((PowerManager) getSystemService("power")).newWakeLock(1, "Socket:WakeLock"); also with wifi WifiManager.WifiLock createWifiLock = ((WifiManager)...
www.b4x.com