1. Android screens are always on/on
CopyCode The Code is as follows: // keep the screen always on
Powermanager PM = (powermanager) getsystemservice (context. power_service );
Mwakelock = PM. newwakelock (powermanager. full_wake_lock | powermanager. acquire_causes_wakeup, lock_tag );
Mwakelock. Acquire ();
Copy codeThe Code is as follows: // release the screen lock
If (null! = Mwakelock ){
Mwakelock. Release ();
}
2. Unlock and lock the android Screen Copy codeThe Code is as follows: // unlock the screen
Keyguardmanager = (keyguardmanager) getsystemservice (keyguard_service );
Keyguardlock = keyguardmanager. newkeyguardlock (lock_tag );
Keyguardlock. disablekeyguard ();
// Screen lock
Keyguardlock. reenablekeyguard ();
3. Related Permissions Copy codeThe Code is as follows: <uses-Permission Android: Name = "android. Permission. disable_keyguard"/>
<Uses-Permission Android: Name = "android. Permission. wake_lock"/>