防止Android系统休眠

添加权限:

   


获取服务:

PowerManager manager = (PowerManager) getSystemService(POWER_SERVICE);
        mWakeLock = manager.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP | 

PowerManager.SCREEN_BRIGHT_WAKE_LOCK, getClass().getName());


获取锁:

mWakeLock.acquire();


释放锁:

if (mWakeLock.isHeld()){
        mWakeLock.release();
        }

你可能感兴趣的:(防止Android系统休眠)