Unlock, wake up screen for Keyguardmanager,keyguardlock,powermanager,powermanager.wakelock
Required Permissions:
Copy Code code as follows:
<uses-permission android:name= "Android.permission.WAKE_LOCK"/>
<uses-permission android:name= "Android.permission.DISABLE_KEYGUARD"/>
Copy Code code as follows:
Lock screen, wake related
Private Keyguardmanager km;
Private Keyguardlock KL;
Private PowerManager pm;
Private Powermanager.wakelock WL;
private void Wakeandunlock (Boolean b)
{
if (b)
{
Get Power Manager Object
Pm= (PowerManager) Getsystemservice (Context.power_service);
Gets the Powermanager.wakelock object, and the following argument | Indicates that two values are passed in at the same time, and the last is the tag for debugging
WL = Pm.newwakelock (Powermanager.acquire_causes_wakeup | Powermanager.screen_bright_wake_lock, "BRIGHT");
Light up the screen
Wl.acquire ();
Get keyboard Lock Manager Object
Km= (Keyguardmanager) Getsystemservice (Context.keyguard_service);
KL = Km.newkeyguardlock ("UnLock");
Unlock
Kl.disablekeyguard ();
}
Else
{
Lock screen
Kl.reenablekeyguard ();
Release Wakelock, turn off the lights.
Wl.release ();
}
}