Android device locked by code
<p>Any one how to Screen display will be Dim on android device by coding...
 i used below code but it is not working proper.
When i click On or Off button i want to android device screen should we Dim or Bright but it is not happening please help me...  </p>

<pre><code> @Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    off = (Button) findViewById(R.id.btnBackLightOff);
    on = (Button) findViewById(R.id.btnBackLightOn);

    final PowerManager pm = (PowerManager) this.getSystemService(Context.POWER_SERVICE);
    // mWakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK|PowerManager.ON_AFTER_RELEASE, "");


    off.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            System.out.println("back light off method");
            mWakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "My Tag");

            mWakeLock.acquire();

        }
    });

    on.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            System.out.println("on method");
            mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "My Tag");
            mWakeLock.acquire();
        }
    });

}

@Override
public void onDestroy() {
    System.out.println("on destroy method");
    this.mWakeLock.release();
    super.onDestroy();
}
</code></pre>
