android-setting system and application level screen brightness

Source: Internet
Author: User

/** * 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.