I'm using this method to set the screen to full brightness.
@SuppressLint("NewApi")
private void setFullBright() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.CUPCAKE) {
WindowManager.LayoutParams windowParams = getWindow().getAttributes();
windowParams.screenBrightness = 1.0f;
getWindow().setAttributes(windowParams);
}
}
If I want the full brightness to be set on the entire life of the Activity's screen, is the onCreate method the best place to call it?
Is there an XML flag that can achieve this? Something like android:keepScreenOn="true" that mirrors the functionality of adding WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON in code?
WindowManager.LayoutParams.BRIGHTESS_OVERRIDE_FULL
instead of1.0F
. There is alsoBRIGHTNESS_OVERRIDE_NONE
to reset the brightness to the device setting, andBRIGHTNESS_OVERRIDE_OFF
to turn the brightness all the way down. – Cohobate