Android上的Cordova应用程序 - 屏幕可能无法入睡

Mic*_*l B 0 android cordova android-4.4-kitkat

我正在使用cordova构建Android应用程序.此应用程序应以全屏模式运行,屏幕可能永远不会关闭.我对设备进行了完全的根控制 - 所有这些都安装在Android 4.4上 - 安装了应用程序.

我已经设定

Developer options -> Stay awake -> checked

并在

Display->Sleep

我设置了最高值,即30分钟.这些设备都连接到它们的电源上.

我的config.xml如下所示:

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.project.name" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>Project </name>
    <description>
      Project
    </description>
    <author email="my@email.com">
      Test
    </author>
    <content src="index.html" />
    <plugin name="cordova-plugin-whitelist" spec="1" />
    <access origin="*" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
    <platform name="android">
      <allow-intent href="market:*" />
      <splash src="res/screen/android/test.png" />
      <preference name="Fullscreen" value="true" />
      <preference name="KeepRunning" value="true"/>
      <preference name="InAppBrowserStorageEnabled" value="true"/>
      <preference name="LoadingDialog" value="Application is loading"/>
      <preference name="ErrorUrl" value="error.html"/>
      <preference name="LogLevel" value="VERBOSE"/>
    </platform>
    <platform name="ios">
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
    </platform>

</widget>
Run Code Online (Sandbox Code Playgroud)

我的问题是,在我在显示选项中设置的时间之后,屏幕会变暗(不完全关闭).例如,屏幕保持亮30分钟,之后它确实保持亮起,但背光非常暗.

我能做些什么,屏幕保持亮丽?

Mic*_*l B 5

我发现了一个插件,它为我做了诀窍:

cordova plugin add https://github.com/EddyVerbruggen/Insomnia-PhoneGap-Plugin.git
Run Code Online (Sandbox Code Playgroud)

然后在Javascript中:

window.plugins.insomnia.keepAwake()
Run Code Online (Sandbox Code Playgroud)

像预期的那样工作,屏幕始终打开.