我使用此代码来降低屏幕亮度,但它仅适用于 android 4.4--。当我在 android 5++ 中测试时,它会在 Activity 打开时工作,在我完成/关闭 Activity 之后,屏幕亮度会返回之前的默认设置。如何在 android 5.0++ 中保持屏幕亮度设置
cResolver = getContentResolver();
window = getWindow();
android.provider.Settings.System.putInt(cResolver,
android.provider.Settings.System.SCREEN_BRIGHTNESS,75);
WindowManager.LayoutParams layoutpars = window.getAttributes();
layoutpars.screenBrightness = 75 / (float) 255;
window.setAttributes(layoutpars);