Android點亮手機屏幕
記得加權限<uses-permission android:name="android.permission.WAKE_LOCK"></uses-permission>
- PowerManager pm = (PowerManager)getSystemService(POWER_SERVICE);
- PowerManager.WakeLock mWakelock = pm.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP |PowerManager.FULL_WAKE_LOCK, "WakeLock");
- mWakelock.acquire();//喚醒屏幕
- //......
- mWakelock.release();//釋放
Android屏幕解鎖
記得加權限<uses-permission android:name="android.permission.DISABLE_KEYGUARD"></uses-permission>
- //獲取一個鍵盤鎖對象
- KeyguardManager mManager = (KeyguardManager)getSystemService(KEYGUARD_SERVICE);
- KeyguardLock mKeyguardLock = mManager.newKeyguardLock("Lock");
- //讓鍵盤鎖失效
- mKeyguardLock.disableKeyguard();