I want the button to turn on and off the sleep mode in the application. I know how to turn it on:

getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); 

but how to turn off not sleep I can not

    1 answer 1

     getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); 

    You can read about the flags in the documentation: https://developer.android.com/reference/android/view/Window.html#clearFlags(int)