title: Decrease the brightness of the screen on button click
body: <p>I have a problem that I want to decrease the brightness of the screen on the button click but failed to do that. I don't know why? I have written the code of few lines but it doesn't work for me. Please suggest me the right solution regarding the same.</p>
  
  <p><strong>Code:</strong></p>
  
  <pre><code>private void setBrightness() {  
  
          try {
              int curBrightnessValue = android.provider.Settings.System.getInt(getContentResolver(), android.provider.Settings.System.SCREEN_BRIGHTNESS);
              WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
              layoutParams.screenBrightness = curBrightnessValue/100.0f;
              getWindow().setAttributes(layoutParams);
          } catch (SettingNotFoundException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
        }  
  </code></pre>