title: How do i lock phone programmatically android
body: <p>Ho do i lock my android phone programmatically ?
  I tried following <a href="http://rdcworld-android.blogspot.in/2012/03/lock-phone-screen-programmtically.html" rel="noreferrer">this</a> example. But when i click on the enable button the Activity pops up for few milliseconds and then closes automatically</p>
  
  <p>The log shows no error just this log</p>
  
  <pre><code> Log.i("DeviceAdminSample", "Admin enable FAILED!");
  </code></pre>
  
  <p>Can any one tell me how to lock the android screen (Like the lock when make to many attempts in pattern lock and the phone locks down)</p>
  
  <p>Any help is appreciated</p>