Search code examples
javaandroidbrightness

Java android - change brightness for my application


how can i change application brightness? I know this method

WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
layoutParams.screenBrightness = (value);
getWindow().setAttributes(layoutParams);

BUT, this method can change just view (activity) brightness, I want to change brightness for all activities in my application. How can I do it?

Also I do not want to change system brightness manually!! So just brightness for all activities JUST in my application.

Thank you for your answers!


Solution

  • I'm not sure there's an easy way to do that. I would save the brightness value the device is on when the user launches the app, then set the brightness to whatever value you want, and reset the brightness to the initial saved value when the user exits the app.