android - navigator.app.exitApp() not working - timers still running

3,532 views
Skip to first unread message

elsigh

unread,
Jan 28, 2013, 4:53:51 PM1/28/13
to phon...@googlegroups.com
In my app, we call navigator.app.exitApp() if the user hits the back button on the home screen.
While it does "close" our app and take the user back to the home screen, our timers are still running and we're making network requests, etc..

My expectation is that exitApp is the equivalent for force stop or something and that it should destroy our Activity.

Reality? ;)

Simon MacDonald

unread,
Jan 28, 2013, 5:06:19 PM1/28/13
to phonegap
navigator.app.exitApp() calls Activity.finish() so you app should be
completely taken down.

Repo?

Simon Mac Donald
http://hi.im/simonmacdonald
> --
> -- You received this message because you are subscribed to the Google
> Groups "phonegap" group.
> To post to this group, send email to phon...@googlegroups.com
> To unsubscribe from this group, send email to
> phonegap+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/phonegap?hl=en?hl=en
>
> For more info on PhoneGap or to download the code go to www.phonegap.com
>
> To compile in the cloud, check out build.phonegap.com
> ---
> You received this message because you are subscribed to the Google Groups
> "phonegap" group.
> To unsubscribe from this group, send email to
> phonegap+u...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

elsigh

unread,
Jan 28, 2013, 5:23:13 PM1/28/13
to phon...@googlegroups.com
If you download Twist (1.0.35) from the Google Play Store right now (before an update this afternoon) and launch, then hit the back button (and monitor adb logcat | grep Console) you'll see our app continuing to make requests for an endpoint titled /notifications/get.

I can also send you an APK.

Will

unread,
Feb 15, 2013, 7:33:33 AM2/15/13
to phon...@googlegroups.com
chronophile

How to safely exit a phonegap app in android?

Hi I'm trying to get my app in cordova 2.1 to kill after a button is clicked in the app's main menu.
In JS I tried using

navigator.app.exitApp();

but the app still appears to be running in the background.I read that you can change a "exit-on-suspend" variable in thge config file, but I would still like to suspend normally with the home button.

Also. I heard that putting in a button killing the app is frowned upon and may get your app rejected. Why is this? What else would I do if I wanted to close the app and stop it from running in the background?

thanks

Will

Chris Haley

unread,
Feb 22, 2013, 9:35:22 AM2/22/13
to phon...@googlegroups.com
Simon,

What elsigh (above) and Will (below) described is true.  It is not the expected result, but it is what is happening.  Timers continue to run in the background after navigator.app.exitApp() has been called.  I'm going to try to see if killing the timer right before exitApp() is called solves the problem.  I've verified this as my app uses a timer to search for images and upload them to a server and they continue to flood in even after the app has been closed.

thanks,
~Chris

Simon MacDonald

unread,
Feb 22, 2013, 1:57:23 PM2/22/13
to phonegap
Have you tried setting:

    super.setBooleanProperty("keepRunning", false);

in your onCreate method?

To unsubscribe from this group and stop receiving emails from it, send an email to phonegap+u...@googlegroups.com.

Chris Haley

unread,
Feb 22, 2013, 2:01:57 PM2/22/13
to phon...@googlegroups.com
No I haven't -- that's the first I've seen that.  What's the scope of that property and what all does it affect?

Simon MacDonald

unread,
Feb 22, 2013, 2:03:41 PM2/22/13
to phonegap
It stops the JS from running when your app is put into the background.

Chris Haley

unread,
Feb 22, 2013, 2:09:14 PM2/22/13
to phon...@googlegroups.com
Wouldn't that be used for it I wanted to background (press home) the app?  I want the JS to keep running if it's backgrounded but not if it's exited completely.

Chris Haley

unread,
Feb 27, 2013, 12:41:15 PM2/27/13
to phon...@googlegroups.com
Any word on this?  I currently have the app ask if the user wants to quit.  If they confirm that they do want to quit, I call clearInterval() on the timer ID and then navigator.app.exitApp().  That keeps the javascript from running when it exits.  However, I still don't feel like it's not fully quitting.  I can go into the app manager and click, "Force close" which I would think should not be enabled if the app is not running.
Reply all
Reply to author
Forward
0 new messages