当在cordova中单击应用程序图标启动器时如何恢复应用程序
how to resume the application when click app icon launcher in cordova?
我正在使用cordova phonegap开发移动应用程序。我现在正在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>
编辑:查看更多详细信息:
我有一个计数器,从 0 开始,每秒递增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"/>
我尝试了这个解决方案,它对我有效
添加 android:launchMode="singleInstance"
活动标签在AndroidManifest.xml,你可以找到它在projectName/platforms/android/AndroidManifest.xml。
相关文章:
- Canvas Html5绘图应用程序,移动画布会导致重大问题
- Emberjs应用程序加载在除Index之外的所有路由上
- 使用电话间隙在Android应用程序中显示SQL Lite的数据
- 在AngularJS应用程序中使用封装指令和路由的推荐方式是什么
- Windows8应用程序(html&Javascript):从图片库(除了文件选择器)显示图像的另一种方式
- angular 1.5应用程序中的导航栏
- 在Web应用程序中使用Highcharts javascript
- angularjs+rails应用程序中未显示模板
- 使用acess代币登录Facebook,并通过网络应用程序离线发布
- 从HTTPGET返回一个自定义对象列表,以便在Angular 2应用程序中使用
- 科尔多瓦页面类应用程序中的多个谷歌地图
- 将JSON存储和恢复到此Ionic应用程序的最有效方法
- 如何检测从打开相机返回后网络应用程序的恢复
- 缓存 Web 应用程序界面并使用 html5 本地存储恢复它
- 如何从WebSocket客户端计算机进入睡眠状态或应用程序进入后台(iPad上的Safari)中恢复
- 不使用JavaScript恢复web应用程序的进度
- 当在cordova中单击应用程序图标启动器时如何恢复应用程序
- 如何处理应用程序在长时间暂停(未终止)后恢复的情况
- Windows 10通用应用程序无法从之前的会话恢复
- 防止安卓离子应用程序在恢复时重新加载