1

I currently have a button in my application that changes the screen brightness, but when I leave that activity, it resets the screen brightness back to normal. I want it to set the brightness throughout the entire application, but go back to normal when I close the application.

This is the code I have now:

public void lower(View view) {
    WindowManager.LayoutParams lp = getWindow().getAttributes();
    float brightness = (float) 0.01;
    lp.screenBrightness = brightness;
    getWindow().setAttributes(lp);  
}

public void raise(View view) {
    WindowManager.LayoutParams lp = getWindow().getAttributes();
    float brightness = (float) -1;
    lp.screenBrightness = brightness;
    getWindow().setAttributes(lp);
}

I was thinking I might be able to do a sort of getScreenBrightness type method on the onCreate() method of my other activities, but this doesn't work.

Thanks for your time.

Eichhörnchen
  • 592
  • 2
  • 12
  • 27

0 Answers0