2014-07-05 31 views
1

我正在开发与cordova手机应用程序的移动应用程序。我现在在iOS平台上测试它,现在在iOS上进行测试。我的问题是当我的应用程序在后台运行时,我点击这个应用程序的启动程序,它被重新初始化。我想要的只是从启动器图标打开应用程序,并继续从它的位置运行。 我试图将config.xml中的属性keepRuning设置为true但它没有工作。如何在点击应用程序图标启动器时在cordova恢复应用程序?

<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="[email protected]" 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每秒计数。如果我按回家,计数器恢复在后台增加。问题是,当我按下应用程序的图标启动器时,计数器将从零重置,因为应用程序已重新创建。

我希望这可以让视图更清晰。

我的问题:

可以这样被科尔多瓦配置或处理,我需要一个插件来做到这一点。
这是可能的和如何? 谢谢

回答

0

我尝试这个解决方案,它为我工作

添加

 android:launchMode="singleInstance" 

的活动标签在AndroidManifest.xml,你可以找到它在项目名称/平台/安卓/ AndroidManifest.xml

就是这样。

0

更新您的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"/> 
+0

当本机平台将应用程序从后台拖出时,resume事件触发。但是当启动器被点击时,应用程序被重新创建而不能恢复。 – mehsen

+0

这将是非常有用的,如果你在这里共享config.xml,谢谢 – byJeevan

+0

我会在一分钟 – mehsen

相关问题