Turn Off Screen

I want a way to make me able that when I press the button, the screen turns off, as if I pressed the power button with one press

like this

https://images.app.goo.gl/JXquneh232wqxDDH7

in AS (android studio) like this, try to find the equation in kodular

WindowManager.LayoutParams params = getWindow().getAttributes();
params.flags |= LayoutParams.FLAG_KEEP_SCREEN_ON;
params.screenBrightness = 0;
getWindow().setAttributes(params);
Flag Value                CPU   Screen  Keyboard

PARTIAL_WAKE_LOCK On* Off Off
SCREEN_DIM_WAKE_LOCK On Dim Off
SCREEN_BRIGHT_WAKE_LOCK On Bright Off
FULL_WAKE_LOCK On Bright Bright

1 Like