screen off on button click
<p>i want to turn the screen of the device on button click,The code i used is as the follows</p>

<pre><code>public class MainActivity extends Activity {

Button powerOff;
int amountOfTime =0;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

powerOff = (Button)findViewById(R.id.button1);
powerOff.setOnClickListener(new View.OnClickListener() {

    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
        PowerManager manager = (PowerManager) getSystemService(Context.POWER_SERVICE);

        // Choice 1
        manager.goToSleep(amountOfTime);

        // Choice 2
        PowerManager.WakeLock wl = manager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Your Tag");
        wl.acquire();
        wl.release();
    }
});
}
</code></pre>

<p>also given a permission </p>

<pre><code>       &lt;uses-permission android:name="android.permission.WAKE_LOCK"/&gt;
</code></pre>

<p>Still it showing an exception that</p>

<pre><code>   01-14 16:06:00.875: E/AndroidRuntime(9317): FATAL EXCEPTION: main
   01-14 16:06:00.875: E/AndroidRuntime(9317): java.lang.SecurityException: Neither user 10079  nor current process has android.permission.DEVICE_POWER.
   01-14 16:06:00.875: E/AndroidRuntime(9317):  at android.os.Parcel.readException(Parcel.java:1322)
   01-14 16:06:00.875: E/AndroidRuntime(9317):  at android.os.Parcel.readException(Parcel.java:1276)
  01-14 16:06:00.875: E/AndroidRuntime(9317):   at android.os.IPowerManager$Stub$Proxy.goToSleep(IPowerManager.java:341)
  01-14 16:06:00.875: E/AndroidRuntime(9317):   at android.os.PowerManager.goToSleep(PowerManager.java:464)
</code></pre>
