michael michael - 2 months ago 15
Android Question

Programmatically disable screen timeout

From this post, Android disable screen timeout while app is running, I can disable screen timeout by

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


My question is am I safely enable screen timeout by

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

Answer Source

Do you just want the screen to time out after you've closed your application? Or is something inside your application going to reset the screen timeout so that it will happen even while your app is running?

If the former I don't think you need to do anything, when you're app is stopped the screen timeout will return to normal.

If the latter it seems like the snippet you've provided would do the trick. But I have no experience with it so I couldn't be certain.