在HTML5中,我怎么能保持Android设备的屏幕上? [英] In HTML5, how can I keep an Android device’s screen on?

查看:146
本文介绍了在HTML5中,我怎么能保持Android设备的屏幕上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用JQuery开发一个App的HTML5。

We are developing an App in HTML5 using JQuery.

有没有一种方法/方法,在JavaScript或其他技术,保持屏幕上的?

Is there a way/method, in JavaScript or another technology, to keep the screen "on"?

感谢。

推荐答案

有没有办法只写JavaScript或其它Web code以保持在屏幕上,而无需编写至少有一点的java code。

There is no way to ONLY write javascript or other web code to keep the screen on, without writing at least a little java code.

要解释为什么我这么肯定的,如果你是通过HTML5开发一个web应用程序,你必须使用的WebView为您的应用程序来承载你的HTML,JavaScript的code的主要画面。所以,你的网络code并不直接在应用程序运行,但采用的是查看其持有人。正如你可以猜到从甚至没有在当地的部分运行某些code,你不能只锁定屏幕。

To explain why I am so certain, if you are developing a web app through html5 you MUST use a WebView as the main "screen" of your application to host your html,javascript code. So your "web code" does not directly run in the application but uses a View as its holder. As you can guess you can't just lock the screen from some code that is not even running in the native part.

我可以提供一个非常容易和简单的方法来保持屏幕,如果你不是机器人编程方面的专家。在第一个活动,一个使用的WebView我猜,加入的onCreate

I can provide a very easy and simple way to keep the screen on if you are not an expert in android programming. In the first activity, that uses the WebView I guess, add in onCreate after super:

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

这篇关于在HTML5中,我怎么能保持Android设备的屏幕上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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