Im using the following code to keep the screen on:
this.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
Is there any way to disable/remove the FLAG_KEEP_SCREEN_ON
later in the code? (I want the screen to fadeout normally).
Thanks!
You could probably do something like this
this.getWindow().setFlags(this.getWindow().getFlags() & ~WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
Did you look at the API? There's also this method
http://developer.android.com/reference/android/view/Window.html#clearFlags%28int%29
this.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
I have not tried this either yet.
I imagine this will work to check if the flag is set:
this.getWindow().getFlags() & WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
Edit: As per the comments, apparently this is how you get the value of the flag.
this.getWindow().getAttributes().flags & WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
There might be a method for that too, you should look at the API doc.
Try this
getWindow().clearFlags(android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
Also read this