// 申请电源锁,禁止休眠
private WakeLock mWakeLock = null;
private void acquireWakeLock() {
if (null == mWakeLock) {
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, this
.getClass().getCanonicalName());
if (null != mWakeLock) {
mWakeLock.acquire();
}
}
}
// 释放设备电源锁
private void releaseWakeLock() {
if (null != mWakeLock) {
mWakeLock.release();
mWakeLock = null;
}
}