For everyone who's trying to achieve the same in a DialogFragment
. Applying the params to getActivity().getWindow()
won't help since the window of the Activity
is not the same as the window the Dialog
is running in. So you have to use the window of the dialog - see following snippet:
getDialog().getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
WindowManager.LayoutParams params = getDialog().getWindow().getAttributes();
params.screenBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_FULL;
getDialog().getWindow().setAttributes(params);
And to answer the original question: No there is no way to set this via XML.