0

I am developing an app using PhoneGap system. Currently when the user switch to another app and then come back to the app, it starts from scratch as if the user is opening it once again.

Now I have heard of the Service that android has but since my class is already extended, I cannot extend it with Service. Do you know of any solution that I can do to solve this small problem.

Currently my code is as follows:

public class MainActivity extends DroidGap {
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        super.init();

        super.setBooleanProperty("keepRunning", true);

        super.setIntegerProperty("loadUrlTimeoutValue", 50000); 
        super.loadUrl("file:///android_asset/www/index.html",50000);
     }
}

Thanks,

Keith Spiteri

keith Spiteri
  • 259
  • 1
  • 6
  • 22

1 Answers1

2

Open your config.xml in "res/xml/config.xml" and locate for "preference" tags.

Add this line/tag before or after other preferences tags.

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

This is a solution for your question, it's simple, the app will keep running when your application is hidden, and he'll close when you close the application.

It's it. I hope I helped you.

Att. Rodrigo

Rodrigo Brun
  • 121
  • 1
  • 4
  • I forgot to send to you this [link](http://docs.phonegap.com/en/2.7.0/guide_project-settings_android_index.md.html) , you can see another preferences to your config.xml file. :) – Rodrigo Brun Feb 13 '14 at 15:25