Add this permission to the AndroidManifest.xml file
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
and
KeyguardManager mgr = (KeyguardManager)getSystemService(Activity.KEYGUARD_SERVICE); KeyguardLock lock = mgr.newKeyguardLock(KEYGUARD_SERVICE); lock.reenableKeyguard();
source share