This article describes the Android programming to prohibit the system lock screen and Jianjiang screen method. Share to everyone for your reference, specific as follows:
Demand:
At some point, the task finishes, closes the screen, opens the screen at some point, continues to perform the task
Usually, do not set the screen often bright, the system will automatically lock the screen, lock screen can not unlock from the code (doubt), so my practice is only to let the system close the screen, but not the screen!
Wakelock lock, UnLock;
Keyguardmanager km;
Keyguardlock KL;
UnLock = Pm.newwakelock (Powermanager.acquire_causes_wakeup | Powermanager.screen_bright_wake_lock, "BRIGHT");
Get keyboard lock Manager Object
km = (keyguardmanager) getsystemservice (context.keyguard_service);
KL = Km.newkeyguardlock ("UnLock");
void Lockscreen () {
//Lock screen
kl.reenablekeyguard ();
Release Wakelock, turn off the light
if (Unlock.isheld ())
unlock.release ();
}
void Unlockscreen () {
//lit screen
if (!unlock.isheld ())
unlock.acquire ();
Unlock
kl.disablekeyguard ();
}
Test code, call the test code, you manually press the power button to lock the screen, 5s you will see the screen light up
{
lockscreen ();
Getlistview (). GetHandler (). postdelayed (New Runnable () {
@Override public
void Run () {
unlockscreen ();
}
}, 5000);
break;
I hope this article will help you with the Android program.