2013-10-16 155 views
1
public static void setBrightness(Activity activity, Float brightness) { 
    WindowManager.LayoutParams lp = activity.getWindow().getAttributes(); 
    if (0 < brightness && brightness <= 1) { 
     lp.screenBrightness = brightness; 

    } 
    activity.getWindow().setAttributes(lp); 
} 

我使用此代碼來更改屏幕亮度,但在自動亮度打開時它不起作用。當自動亮度開啓時如何更改屏幕亮度?

如何在自動亮度開啓時更改屏幕亮度?而且我不會改變系統亮度,它應該只是改變當前的活動。

回答

0

使用此關閉自動亮度:

Settings.System.putInt(getContentResolver(), 
SCREEN_BRIGHTNESS_MODE, SCREEN_BRIGHTNESS_MODE_MANUAL); 

如果你想將其設置回自動再次使用此:

Settings.System.putInt(getContentResolver(), 
SCREEN_BRIGHTNESS_MODE, SCREEN_BRIGHTNESS_MODE_AUTOMATIC);