简体   繁体   English

当app(带有Phonegap)打开时,避免android关闭屏幕

[英]Avoid android from shutting screen off while app (with Phonegap) is on

I'm programming an Android application, and I would like to do so that it doesn't shut down the screen, ever.Pretty much like a car gps app that keeps the screen on. 我正在编写一个Android应用程序,我想这样做,它不会关闭屏幕,永远。很像一个汽车GPS应用程序,保持屏幕。

Would someone know how to do this with phonegap ? 有人知道怎么用ph​​onegap这样做吗?
If its not possible in Javascript, is there an easy way to do it in Java but inside the main Phonegap function ? 如果它不可能在Javascript中,是否有一种简单的方法可以在Java中进行,但在主要的Phonegap函数中?

Thank you 谢谢

use this property in the ManiFestFile 在ManiFestFile中使用此属性

<uses-permission android:name="android.permission.WAKE_LOCK"/>

and add this in the required Activity 并将其添加到所需的活动中

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM