android studio keep device awake

Java
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
Source

Also in Java: