/** * Get current screen Brightness mode * screen_brightness_mode_automatic=1 Adjust screen brightness for yourself * screen_brightness_mode_manual=0 to manually adjust screen brightness */pri vate int Getscreenmode () {int screenmode=0; try{Screenmode = Settings.System.getInt (Getcontentresolver (), Settings.System.SCREEN_BRIGHTNESS_MODE); } catch (Exception localexception) {} return screenmode; }/** * Gets the current screen brightness value 0-255 */private int getscreenbrightness () {int screenbrightness=255; try{screenbrightness = Settings.System.getInt (Getcontentresolver (), Settings.System.SCREEN_BRIGHTNESS); } catch (Exception localexception) {} return screenbrightness; }/** * Set the current screen brightness mode * screen_brightness_mode_automatic=1 to adjust the screen brightness for yourself * screen_brightness_mode_manual=0 to manually adjust the screen brightness */P rivate void Setscreenmode (int paramint) {try{Settings.System.putInt (Getcontentresolver (), Settings.System.SCREEN_ Brightness_mode, Paramint); }catch (Exception localexception) {localexception.printstacktrace (); } } /* * Set system level screen brightness value 0-255<span style= "White-space:pre" ></span> * */private void savescreenbrightness (int Paramint) {try{Settings.System.putInt (Getcontentresolver (), Settings.System.SCREEN_BRIGHTNESS, paramint); } catch (Exception localexception) {localexception.printstacktrace (); }}/** * Set the current screen brightness value, effective in time 0-255<span style= "White-space:pre" ></span> * This method only applies to the current application screen brightness */private Voi d setscreenbrightness (int paramint) {Window Localwindow = GetWindow (); Windowmanager.layoutparams locallayoutparams = Localwindow.getattributes (); float F = paramint/255.0f; Locallayoutparams.screenbrightness = f; Localwindow.setattributes (Locallayoutparams); }
Copyright notice: This article blog original articles, blogs, without consent, may not be reproduced.
Android-the system and application-level screen brightness