Correct method for setKeepScreenOn / FLAG_KEEP_SCREEN_ON

Try this answer:

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

getWindow is a method defined for activities, and won’t require you to find a View first.

Leave a Comment