Keep Screen On(Not sleep)

Basically, when running Android application.
Device sleeps some times after no operation(this is user setting).
But, we don’t want the device sleep for some reasons.

Keep on

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

getWindow() is Activity method

Clear this settings

If you restore settings please use it

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

just flag off.