Possible Duplicate:
Lock the Android device programmatically
I want to lock the screen through my program. I am using the following code to do the same..But it's not working for me..I don't know where I am wrong..even I am not getting any errors in logcat..I am using 1.6
public class KeyGaurd extends Activity {
KeyguardManager keyguardManager;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
keyguardManager =
(KeyguardManager)getSystemService(Context.KEYGUARD_SERVICE);
KeyguardLock lock = keyguardManager.newKeyguardLock(KEYGUARD_SERVICE);
lock.reenableKeyguard();
}
And I used the permission also
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"></uses-permission>