Im creating a live chat messenger just like LINE, Im using socket.io, but when my device goes to sleep mode, the connection get lost. Right now I solve this problem using PARTIAL_WAKE_LOCK but I read that it affect the battery life. There is another way to solve this problem?
pd I also try to use onStartCommand START_STICKY but this neither work.
thanks in advance!!
this is part of my code
@Override
public void onCreate(){
        handler = new Handler();
        mSocket.connect();
        localStorage = new LocalStorage(this);
        String room = localStorage.getRoom();
        mSocket.emit("join room", room);
        mSocket.on("chat message", onNewMessage);
        PowerManager pm = (PowerManager) this.getSystemService(Context.POWER_SERVICE);
        wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MessageService");
        wl.acquire();
}
@Override
public void onDestroy(){
    wl.release();
    super.onDestroy();
    mSocket.off("chat message", onNewMessage);
    mSocket.disconnect();
}