编程方式禁用屏幕超时 [英] Programatically disable screen timeout

查看:98
本文介绍了编程方式禁用屏幕超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从这个职位,<一个href=\"http://stackoverflow.com/questions/4195682/android-disable-screen-timeout-while-app-is-running\">Android禁用屏幕超时而应用程序正在运行,我可以通过

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);

感谢。

推荐答案

你只是想在屏幕时,您关闭申请后?或者是你的应用程序中的东西要重置屏幕超时,使其即使在您的应用程序运行时发生的?

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.

这篇关于编程方式禁用屏幕超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆