1
我使用此代碼來降低屏幕亮度,但它只適用於Android 4.4--。當我在android 5 ++中測試時,當它完成/關閉Activity後,它會在Activity打開時工作,然後屏幕亮度將返回默認設置。如何在Android 5.0 ++中保持屏幕亮度設置無法保持屏幕亮度設置在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);