views:

224

answers:

1

how to programmaticaly lock screen android?

+3  A: 

Check this class : com.android.internal.policy.impl.LockScreen

Referenced from here: http://stackoverflow.com/questions/3219950/can-you-lock-screen-from-your-app

Also check code for enabling and disabling lock Screen in Android. (Referenced from here)

KeyguardManager keyguardManager = (KeyguardManager)getSystemService(Activity.KEYGUARD_SERVICE); 
KeyguardLock lock = keyguardManager.newKeyguardLock(KEYGUARD_SERVICE); 

For locking the screen use,

lock.reenableKeyguard();

and for disabling the lock use,

lock.disableKeyguard()
YoK
i test this code,but this not working
Mecid
Can you share code what you tried? and What issues you are facing with it ?
YoK
This code is not useful
Ashay