title: Change brightness screen with volume keys in Android
body: <p>I want to change the brightness of screen with volume keys. I used this code, but it doesn't work: </p>
  
  <pre><code>@Override
      public boolean onKeyDown(int keyCode,KeyEvent keyEvent){
          WindowManager.LayoutParams layout = getWindow().getAttributes();
  
          if(keyEvent.getAction() == KeyEvent.ACTION_DOWN){
              switch (keyCode){
                  case KeyEvent.KEYCODE_VOLUME_DOWN:
                      layout.screenBrightness -= 0.1;
                      getWindow().setAttributes(layout);
                      break;
                  case KeyEvent.KEYCODE_VOLUME_UP:
                      layout.screenBrightness += 0.1;
                      getWindow().setAttributes(layout);
                      break;
              }
  
          }
          return super.onKeyDown(keyCode , keyEvent);
      }
  </code></pre>
  
  <p>When I press volume key down/up ringer volume is changed?</p>