One: Only change the current program Android screen brightness
(1) Method:
Lp.screenbrightness value 0.0--1.0※ Set Value (float) range, default is less than 0 (system setting), 0.0 (dark) ~1.0 (bright) ※ Call processing place, for example, Activity.oncreate () and so on
Code:
Windowmanager.layoutparams LP = GetWindow (). GetAttributes ();
lp.screenbrightness = 1.0f;
GetWindow (). SetAttributes (LP);
Note: 1, B is a floating-point number from 0~1, indicating brightness
2, when we encounter the activity as a sub-activity into the tabactivity or ViewGroup class container, the above method is usually not successful.
In child activity, the screen brightness does not change. Because the dimming scope changes, the brightness is changed before the activity. The tabactivity or ViewGroup container is now modified as a child activity. Therefore, the GetParent () method is required to obtain the parent and then set. 3.
(2) Recovery
When you leave the current acitivity, the brightness of the screen is restored to its original brightness. The lp.screenbrightness is also set to-1 (WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE), it also restores the screen to its original brightness (i.e. system settings).
(3) Minimum brightness
WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE, the official document says this value can set the screen brightness to the lowest brightness (Lowest brightness). The real sense is to set the screen to full black and the screen will not respond to touch. On G3 (CM6), setting the screen to the minimum brightness value is
0.004(accuracy 0.001), when the screen is basically all black, but still can control. Less than 0.004 (accuracy 0.001), the screen loses control. 0.01 is also a value to record, the screen brightness is low enough, when you can still see things. These values should be device-related and cannot be set in a random setting.
Android adjusts screen brightness