javascript - 单击 Cordova 中的应用程序图标启动器时如何恢复应用程序?

标签 javascript android ios cordova

我正在使用 cordova 开发移动应用程序音位间隙。我现在正在 android 平台上测试它,稍后在 ios 上进行测试。我的问题是,当我让应用程序在后台运行时,我单击该应用程序的启动器,它会重新初始化。我想要的只是从启动器图标打开应用程序并继续从它所在的位置运行。 我尝试将 config.xml 中的属性 keepRuning 设置为 true,但没有成功。

   <preference name="keepRunning" value="true" />

这是 config.xml:

     <?xml version="1.0" encoding="utf-8" standalone="no"?>
     <widget xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0" id="com.coolappz.HTML5Application1" version="1.0.0">
        <name>HTML5Application1</name>
        <description>Cordova Application</description>
        <author email="info@com.coolappz" href="http://www.coolappz.com">user</author>
        <access origin="*"/>
        <preference name="fullscreen" value="true"/>
        <preference name="webviewbounce" value="true"/>
        <preference name="keepRunning" value="true" />

    </widget>

编辑: 欲了解更多详情:

我有一个从开始并每秒递增 1 的计数器。 如果我按 home,计数器会在后台恢复递增。问题是,当我按下应用程序的图标启动器时,计数器会从零重置,因为应用程序已重新创建。

我希望这能让观点更加清晰。

我的问题:

这可以通过cordova配置来处理吗?或者我需要一个插件来做到这一点。
这可能吗?如何实现? 谢谢

最佳答案

更新您的 config.xml 以查找缺少的首选项。 :

    <preference name="permissions"                value="none"/>
     <!-- Customize your app and platform with the preference element. -->
    <preference name="phonegap-version"           value="3.3.0" />    <!-- all: current version of PhoneGap -->
    <preference name="orientation"                value="default" />        <!-- all: default means both landscape and portrait are enabled -->
    <preference name="target-device"              value="universal" />      <!-- all: possible values handset, tablet, or universal -->
    <preference name="fullscreen"                 value="true" />           <!-- all: hides the status bar at the top of the screen -->
   <preference name="webviewbounce"              value="false" />           <!-- ios: control whether the screen 'bounces' when scrolled beyond the top -->
   <preference name="prerendered-icon"           value="true" />           <!-- ios: if icon is prerendered, iOS will not apply it's gloss to the app's icon on the user's home screen -->
   <preference name="stay-in-webview"            value="false" />          <!-- ios: external links should open in the default browser, 'true' would use the webview the app lives in -->
   <preference name="ios-statusbarstyle"         value="black-opaque" />   <!-- ios: black-translucent will appear black because the PhoneGap webview doesn't go beneath the status bar -->
   <preference name="detect-data-types"          value="true" />           <!-- ios: controls whether data types (such as phone no. and dates) are automatically turned into links by the system -->
   <preference name="exit-on-suspend"            value="false" />          <!-- ios: if set to true, app will terminate when home button is pressed -->
   <preference name="show-splash-screen-spinner" value="true" />           <!-- ios: if set to false, the spinner won't appear on the splash screen during app loading -->
   <preference name="auto-hide-splash-screen"    value="true" />           <!-- ios: if set to false, the splash screen must be hidden using a JavaScript API -->
   <preference name="disable-cursor"             value="false" />          <!-- blackberry: prevents a mouse-icon/cursor from being displayed on the app -->
   <preference name="android-minSdkVersion"      value="10" />              <!-- android: MIN SDK version supported on the target device. MAX version is blank by default. -->
   <preference name="android-installLocation"    value="auto" />           <!-- android: app install location. 'auto' will choose. 'internalOnly' is device memory. 'preferExternal' is SDCard. -->
   <preference name="KeyboardDisplayRequiresUserAction " value="false"/>

关于javascript - 单击 Cordova 中的应用程序图标启动器时如何恢复应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24587476/

相关文章:

android - 如何在Android中的edittext开头添加一个空格?

iOS 9 扩展状态栏错误?

ios - AVPlayer 不在渐进式下载和流式传输之间切换

javascript - 选择具有相同名称但大写的对象属性

javascript - Python 打印与 Javascript console.log()

javascript - 使用 BOXOVER.js 工具提示时 IE 中的选择框问题

android - Flutter Fresh 项目总是在所有 Flutter Channel 中出错

javascript - 如何使用IE在html编辑器中设置光标(7-8)

android - 如何在浏览器中打开本地html页面

ios - objective-c 中 ios 9 的 UserNotificationsUI.framework 错误