I need to set the brightness screen to max level when a Dialog Fragment shows in my application. My application has minimum support of Android SDK 23 and I tried to set the brightness inside onCreate() of my Dialog Fragment like this:
WindowManager.LayoutParams lp = getActivity().getWindow().getAttributes();
float brightness=1.0f;
lp.screenBrightness = brightness;
getActivity().getWindow().setAttributes(lp);
But the brightness screen only changes for a few moments. How can I set the brightness screen to maximum level when dialog was opened and reset it again when fragment dialog was closed?