目前以下代码将屏幕亮度级别设置为0,但它没有使屏幕变暗。有人帮助我。安卓版本是4.0。 提前谢谢。
android.provider.Settings.System.putInt(
context.getContentResolver(),android.provider.Settings.System.SCREEN_BRIGHTNESS, 0);
答案 0 :(得分: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));
答案 1 :(得分: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();
}