lock and unlock screen while clik on button in android
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/4545079/lock-the-android-device-programatically">Lock the android device programatically</a>  </p>
</blockquote>



<p>I try to lock and unlock the screen by click on the button in android. please help me to complete the code. i used following code to lock screen but i face problem in unlocking. please help me its very urgent.</p>

<pre><code>     Window mywindow = getWindow();                  
     WindowManager.LayoutParams lp = mywindow.getAttributes();
     mywindow.addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
     mywindow.setAttributes(lp);

     s=false;
  //   Log.w(LOG_TAG, "Screen goes off!");
     } else {
         lock.setImageResource(R.drawable.unlockicon);
     Window mywindow = getWindow();
     WindowManager.LayoutParams lp = mywindow.getAttributes();
     mywindow.clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
     mywindow.setAttributes(lp);
     s=true;
</code></pre>
