It worked for me just adding this:
Edited: Forgot to take out the protected tag
@Override
void onResume() {
getWindow().addFlags(android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
super.onResume();
}
@Override
void onPause() {
getWindow().clearFlags(android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
super.onPause();
}