i have a chat application.my code has a thread which manages internet connection.
but after some minutes my thread goes sleep.
I know i should use WakeLock
to wake CPU and my thread.
but when i use below code , battery usage goes up.
if (mWakeLock == null) {
mWakeLock = pm.newWakeLock(
PowerManager.PARTIAL_WAKE_LOCK,
"NewOnlineSignalingPowerManagerTag");
}
if (mWifiLock == null) {
mWifiLock = wm.createWifiLock(
WifiManager.WIFI_MODE_FULL,
"NewOnlineSignalingWifiManagerTag");
}
if (!mWakeLock.isHeld()) {
logging.l("mWakeLock.acquire()");
mWakeLock.acquire();
}
if (!mWifiLock.isHeld()) {
logging.l("mWifiLock.acquire()");
mWifiLock.acquire();
}
can you prefer me a better way?