如何使一个phonegap构建应用程序在后台工作 [英] How to make a phonegap build app work in background
问题描述
我需要我的应用程式每隔5分钟一次性记录使用者位置。它工作正常,而手机是活动,但当它不是 setInterval()
的strecth是比他们应该长达5倍。
I need my app to work 24/7 recording the users location every 5 mins. It works fine while the phone is active but when it isn't the setInterval()
's strecth out to be up to 5x longer than they should.
使用phonegap构建,我如何使应用程序工作,因为它应该在后台,而手机空闲?
Using phonegap build, how would I go about making the app work as it should in the background while the phone is idle?
推荐答案
@Marty,
Android和iOS都可以在后台运行,到常规config.xml。
@Marty,
both Android and iOS and run in the background, but require an extension to the regular config.xml.
要清楚Android应用程序使用AndriodManifest.xml。
iOS使用,preferences.plist
To be clear Android apps uses AndriodManifest.xml. iOS uses, preferences.plist
两者都有能力进入后台。然而,在Cordova / Phonegap这不是直接可用,你必须做一个扩展。最好的解释来自Cordova和Phonegap Build。
Both have the ability to go into background. However, in Cordova/Phonegap this is not available directly, you must make an extension. The best explaination are from Cordova and Phonegap Build.
来自Phonegap Build:
开头为:配置文件元素。您将需要为每个添加< gap:config-file>
一个,那么您还需要添加到第一个xml元素,如下所示:
From Phonegap Build:
Start with: Config File Elements. You will need to add <gap:config-file>
one for each, then you will also need to add to the first xml element, like this:
<widget xmlns = "http://www.w3.org/ns/widgets"
xmlns:android = "http://schemas.android.com/apk/res/android"
xmlns:gap = "http://phonegap.com/ns/1.0"
id = "com.bsdmasterindex.googlemapexamples"
version = "1.0.0"
versionCode = "10" >
最重要的项目是 xmlns:android =http: .android.com / apk / res / android
。这只是为android,当然。
The most important item being xmlns:android = "http://schemas.android.com/apk/res/android"
. This is only for android, of course.
使用这个例子是在我的Demo锅炉板为Phonegap Build - 源在git hub。
Examples of using this are in my Demo Boiler plates for Phonegap Build - source available at git hub.
三(3) Phonegap Build Boilerplates for Android和iO
您将需要查看Boilerplate#2。
You will want to look at Boilerplate #2.
本文将有所帮助。
有关Android Manifest xml文件的7个事项
如果您还有其他问题,建议您访问 google groups 。我将很快从我的准备列表中删除Stackoverflow。
If you have further question, I suggest you go to google groups. I will soon be dropping Stackoverflow from my readying list. I willl likely drop on Monday.
Jesse
这篇关于如何使一个phonegap构建应用程序在后台工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!