Code

WindowManager.LayoutParams layout = getWindow().getAttributes();
layout.screenBrightness = 0.5F ; getWindow().setAttributes(layout);

Note

Brightness level 0.1 is 10% and 1.0 is 100%.