Code:
KeyguardManager mgr = (KeyguardManager)getSystemService(Activity.KEYGUARD_SERVICE); KeyguardLock lock = mgr.newKeyguardLock(KEYGUARD_SERVICE); lock.reenableKeyguard();
DOES NOT lock the screen. It just locks the keypad lock. When you run
lock.disableKeyguard();
and press the lock button on the device, it will not lock the keypad lock. To lock the screen programmatically, you must go to the "Device Administrator" and use the locknow () method to lock the device.
source share