I have an chat app with socket.io and make a connection to the server. I don't know witch services and processes are turn off on stand by and when phone is not charging. When phone is on charger app works fine, connection is OK and stable, and foreground service is running. But when is not charging, and phone go to stand by/sleep sometimes app disconnect, or sometimes kill the service.
I try with wakelock and wifilock in onCreate
method in service and connection disconnect usually after 20minutes. It is like I added few more minutes but again the connection is lost.
public void onCreate() {
super.onCreate();
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Hi-tech::PowerWakeLock");
wl.acquire(10000);
WifiManager wm = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
WifiManager.WifiLock wifiLock = wm.createWifiLock(WifiManager.WIFI_MODE_FULL_HIGH_PERF , "MyWifiLock");
wifiLock.acquire();
What else can be the problem?