/** * Get the current screen brightness mode * screen_brightness_mode_automatic=1 to automatically adjust the screen brightness * screen_brightness_mode_manual=0 To manually adjust the screen brightness */priv ate 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 automatically adjust the screen brightness * screen_brightness_mode_manual=0 To manually adjust the screen brightness */pri vate void Setscreenmode (int paramint) {try{Settings.System.putInt (Getcontentresolver (), Settings.System.SCREEN_BR Ightness_mode, Paramint); }catch (Exception localexception) {localexception.printstacktrace (); } } /** * Set the system level screen brightness value 0-255<span style= "White-space:pre" ></span> * */private void savescreenbrightness (int pa Ramint) {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); }
android-setting system and application level screen brightness