Android settings --- brightnesspreference. Java (brightness setting)

Source: Internet
Author: User

1. Signal Process:
Brightnesspreference ----> onbinddialogview (getbrightness) ----> showdialog ----> onpreferencetreeclick ----> onprogresschanged (coming in if there is a change) (setbrightness) -----> ondialogclosed ----> contentobserver-mbrightnessobserver -----> onbrightnesschanged (getbrightness ).

 

2. Related Knowledge points:

Contentobserver-content observer, which is used to observe (capture) database changes caused by a specific URI, and then perform corresponding processing
* Follow these steps to observe a specific URI:
* 1. Create a specific contentobserver derived class. The contentobserver constructor must be reloaded and the onchange () method must be reloaded to process the callback function.
* 2. Use context. getcontentresolover () to obtain the contentresolove object, and then call registercontentobserver () to register the content observer.
* 3. Because the life cycle of contentobserver is not synchronized with activity and service, you need to manually call it if you do not need it.
Unregistercontentobserver () to cancel registration.
*
* Conclusion: contentobserver is mainly used in the following situations:
1. Whether or not the database or data that needs to be frequently checked has changed. It is very economic and time-consuming to operate using threads;
2. perform database events when users do not know, such as sending messages quietly or rejecting text message blacklists;

 

* Public final void registercontentobserver (URI Uri, Boolean policyfordescendents, contentobserver observer)
* Function: registers a contentobserver derived class instance for the specified URI. When the specified URI changes, the instance object is called back for processing.
* Parameter: URI to be observed (you need to register it in urimatcher; otherwise, this URI does not make sense)
* If policyfordescendents is set to false, exact match is performed.
True indicates that the URI derived from the URI can be matched at the same time.
* Instance of the observer contentobserver derived class
*
*
* Public final void unregistercontentobserver (contentobserver observer)
* Function: Disable the observation of a given Uri.
Parameter: Observer contentobserver's derived class instance

3. Public void onprogresschanged (seekbar, int progress, Boolean fromtouch) -------------------- set the brightness using the progress bar control in manual mode;

Public void oncheckedchanged (compoundbutton buttonview, Boolean ischecked) ----------------- select to adjust the brightness automatically or manually;

Private void setbrightness (INT brightness) ------------- this is set brightness! It calls powermanager (Framework \ base \ core \ Java \ Android \ OS \ powermanager. java) and powermanagerservice (Framework \ base \ service \ Java \ com \ Android \ Server \ powermanagerservice. java) interface to adjust the height. mbuttonlight and mkeyboardlight defined in powermanagerservice are both keyboard lights.
Public void setbacklightbrightness (INT brightness );

(Framework \ base \ service \ Java \ com \ Android \ Server \ lightsservice. Java)

(Framework \ base \ Services \ JNI \ com_android_server_lightsservice.cpp)

 

 

 

 

 

 

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.