I'm currently working on a mobile application using PhoneGap with Cordova, testing it on android before moving onto iOS. My issue is that when the app is running in the background and I click on the launcher icon to open it again, it restarts instead of continuing from where it left off.
I tried setting the attribute keepRunning
to true in the config.xml file, but it didn't solve the problem.
<preference name="keepRunning" value="true" />
This is my 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="<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ec85828a83ac8f8383808d9c9c96">[email protected]</a>" 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>
EDIT: For more details:
I have a counter that starts at zero and increases by 1 every second. The counter continues to increment in the background if I press home. However, when I tap the launcher icon, the counter resets to zero because the app is being recreated.
I hope this clarifies the situation.
My question :
Can this issue be resolved through Cordova configuration or do I need a plugin to address it?
Is there a solution available, and if so, how can I implement it?
Thanks