1

I want to change system brightness to the maximum when an activity is launched. I use following examples but they didn't work properly .

Also the system brightness shouldn't change when an application is running.

Change the System Brightness Programmatically

changing screen brightness programmatically in android

How could I achive this process . Any ideas about this ?

Thank you.

Community
  • 1
  • 1
Terance Wijesuriya
  • 1,928
  • 9
  • 31
  • 61

1 Answers1

0

You can use this :

WindowManager.LayoutParams lp = getWindow().getAttributes();
lp.screenBrightness = (float)WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_FULL;
getWindow().setAttributes(lp);

You should note that this method doesn't change system settings, and the brightness will be back to normal once the activity is paused or destroyed,

Honestly, I don't remember how to change system settings' brightness, but once I find it out,I will post another answer.

If you want to change brightness back to normal then replace BRIGHTNESS_OVERRIDE_FULL with BRIGHTNESS_OVERRIDE_NONE.

Hope this helps :D

Omar Hemaia
  • 188
  • 10