title: changing brightness in android programmatically
body: <p>when writing code for changing brightness programmatically in android studio, setContentView, getContentResolver, ChangeBright, findViewById and  getWindow are in red. it says cannot resolve method. why is that so?</p>
  
  <pre><code>private SeekBar brightbar;
  private int brightness;
  private ContentResolver Conresolver;
  private Window window;
  
  @Override
  public void onCreate(Bundle savedInstanceState)
  {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_tab3);
  
      brightbar = (SeekBar) findViewById(R.id.ChangeBright);
  
  
      Conresolver = getContentResolver();
  
      window = getWindow();
  
  
      brightbar.setMax(255);
  
      brightbar.setKeyProgressIncrement(1);
  
      try
      {
  
          brightness = System.getInt(Conresolver, System.SCREEN_BRIGHTNESS);
      }
      catch (SettingNotFoundException e)
      {
  
          Log.e("Error", "Cannot access system brightness");
          e.printStackTrace();
      }
  
  
      brightbar.setProgress(brightness);
  
  
      brightbar.setOnSeekBarChangeListener(new OnSeekBarChangeListener()
      {
          public void onStopTrackingTouch(SeekBar seekBar)
          {
              System.putInt(Conresolver, System.SCREEN_BRIGHTNESS, brightness);
  
              LayoutParams layoutpars = window.getAttributes();
  
              layoutpars.screenBrightness = brightness / (float)255;
  
              window.setAttributes(layoutpars);
          }
  
          public void onStartTrackingTouch(SeekBar seekBar)
          {
  
          }
  
          public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser)
          {
  
              if(progress&lt;=20)
              {
  
                  brightness=20;
              }
              else
              {
  
                  brightness = progress;
              }
  </code></pre>