Android -- PowerManager和PowerManager.WakeLock
PowerManager.WakeLock PowerManager.WakerLock是我分析Standup Timer源代码时发现的一个小知识点,Standup Timer 用WakeLock保证程序运行时保持手机屏幕的恒亮(程序虽小但也做得相当的细心,考虑的很周到)。PowerManager 和PowerManager.WakerLock7用于对Android设备的电源进行管理。 PowerManager:This class gives you control of the power state of the device. PowerManager.WakeLock: lets you say that you need to have the device on. Android中通过各种Lock锁对电源进行控制,需要注意的是加锁和解锁必须成对出现。先上一段Standup Timer里的代码然后进行说明。 private void acquireWakeLock() { if (wakeLock ==null) { Logger.d("Acquiring wake loc...
