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