title: How to lock my tablet screen programmatically
body: <p>When i was trying to implement lock the screen(when unplug the charger) using below code, it is not working. i'm new for the android can any one suggest me. </p>
  
  <pre><code>      case BatteryManager.BATTERY_STATUS_DISCHARGING:
          Log.v("sunil2", "=======discharging");
          statusString = "discharging";
          PowerManager powermanager = ((PowerManager)context.getSystemService(Context.POWER_SERVICE));
          WakeLock wakeLock=powermanager.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "tag");
          if(wakeLock.isHeld()) {
               wakeLock.release();
          }
  </code></pre>