我尝试在打开对话框片段时更改亮度,我将此代码插入oncreate(),但仅更改一秒钟。
try {
curBrightnessValue = Settings.System.getInt(
getActivity().getContentResolver(), Settings.System.SCREEN_BRIGHTNESS);
WindowManager.LayoutParams layout = getActivity().getWindow().getAttributes();
layout.screenBrightness = 1F;
getActivity().getWindow().setAttributes(layout);
} catch (Settings.SettingNotFoundException e) {
e.printStackTrace();
}
在主要片段中有效