Desactivar mantener la pantalla encendida


He utilizado:

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

¿Cómo puedo reanudar el estado predeterminado (no-keep-on)?

Author: Richard Everett, 2011-01-26

3 answers

Creo que esto debería hacerlo:

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

Ver API para más detalles.

 127
Author: Noel,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-01-26 17:30:09

Si en su lugar establece una bandera android:keepScreenOn="true" (documentation) solo en las vistas que necesitan mantener la pantalla encendida, no necesitará restablecer la bandera manualmente.

 17
Author: Alexander Abramov,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-04-05 08:42:51

Otro enfoque

getWindow().setFlags(this.getWindow().getFlags() & ~WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

También lea esto

Y también puede establecer android:keepScreenOn="true" en la vista raíz en xml.

 4
Author: Xar E Ahmer,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-06-16 13:22:11