0

目前以下代码将屏幕亮度级别设置为 0,但没有使屏幕变暗。有人可以帮帮我吗。android 版本是 4.0。提前致谢。

android.provider.Settings.System.putInt(
 context.getContentResolver(),android.provider.Settings.System.SCREEN_BRIGHTNESS, 0);
4

2 回答 2

0
Settings.System.putInt(this.getContentResolver(),
        Settings.System.SCREEN_BRIGHTNESS, 20);

WindowManager.LayoutParams lp = getWindow().getAttributes();
lp.screenBrightness = 0.2f; // 100 / 100.0f;
getWindow().setAttributes(lp);

startActivity(new Intent(this,RefreshScreen.class));
于 2016-04-06T06:55:55.447 回答
0

尝试这个:

public static void wakeDevice(Context context) {
    PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
    PowerManager.WakeLock wakeLock = powerManager.newWakeLock(
            (PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.FULL_WAKE_LOCK
                    | PowerManager.ACQUIRE_CAUSES_WAKEUP), "");

    //calling this will Dim the screen
    wakeLock.acquire();

    //if  you want to release the dim state
    //wakeLock.release();
}
于 2016-04-06T06:57:59.950 回答