Can't keep Screen brightness setting in android 5.0++ -
i use code reduce screen brightness work in android 4.4--. when test in android 5++ work when activity open, after finish/close activity screen brightness return default setting before. how can keep screen brightness setting in 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);
is adaptive brightness enabled on device? mean brightness level falls within user-defined range, rather using single value provide. try disabling before running code posted, , see if makes difference.
settings.system.putint(getcontentresolver(), screen_brightness_mode, screen_brightness_mode_manual)
also, see this question changing value when adaptive mode enabled.
Comments
Post a Comment