Programmatically switching off Android phone
<p>Can we switch off an Android phone programmatically?</p>

<p>Second question: how to lock and unlock the screen in Android?</p>

<p>I am using following snippet but it didn't work for me.</p>

<pre><code>KeyguardManager keyguardManager =
        (KeyguardManager) getSystemService(Activity.KEYGUARD_SERVICE); 
KeyguardLock lock = keyguardManager.newKeyguardLock(KEYGUARD_SERVICE); 

lock.disableKeyguard(); // to disable

lock.reenableKeygaurd();// to enable
</code></pre>

<p>and I used the permission also.</p>
