Lock an Android Phone [duplicate]
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: Lock the android device programatically I want to be able to lock the Android phone with a password when I run a method. Does anyone have a reference or sample code for me to refer. Thanks EDIT I have tried using KeyguardManager mgr = (KeyguardManager)getSystemService(Activity.KEYGUARD_SERVICE); KeyguardLock lock = mgr.newKeyguardLock(KEYGUARD_SERVICE); lock.reenableKeyguard(); as said by the answer below, but I