bluediapente
bluediapente

Reputation: 3976

Is there a way to control how dark the screen gets when it dims?

Is there a way to programmatically set how dark the screen gets when it dims ? I would like to get it as dark as possible without turning it off and locking it.

It could be a setting in the device as long as I can set it via code like how I can set the screen timeout for example:

Settings.System.putInt(getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT, 60000);

Thanks,

Upvotes: 4

Views: 351

Answers (1)

barcodereader
barcodereader

Reputation: 2038

This is how you can dim it on timeout:

Settings.System.putInt(context.getContentResolver(),
Settings.System.SCREEN_BRIGHTNESS, someIntValue);

and

WindowManager.LayoutParams lp = getWindow().getAttributes();
lp.screenBrightness = (float) (someIntValue/ 255.0);
getWindow().setAttributes(lp);

you need to override onUserInteraction() to reset back to regular value for screen brightness.

Upvotes: 2

Related Questions