05-28-2013 07:05 AM
Exiting an app with System.exit() appears to hang the app, until some event occurs (screen backlight time-out, for example), at which point the app dies with one of a number of errors (like "unable to find process" or "failed looking up window").
This does not happen if the app never switches activity. If the app switches to another activity and then back, exit() will no longer terminate the app correctly.
(Same code works 100% of the time on a wide variety of Android devices, from 2.0 to 4.2.)
Is there a definitive way to terminate an application?
05-28-2013 11:03 AM
Android isn't really designed for this.
Why do you want to terminate the application manually, instead of letting the Android runtime do it for you?
05-28-2013 01:24 PM
Android is designed to do this. exit() is clearly specified by the Android API, and all implementations of Android in my (significant) experience conform that specification. Android does it perfectly - it is only the BB Android player that has a problem. Actually, I should say that the same code has been working fine on the PlayBook for the last year as well. It's the Q10 that exhibits this issue (and presumably the Z10).
I want to do it, because this is what the application already does, and I don't want to change it anymore than is necessary to get it to work on the '10. If supporting the '10 is costly, we simply won't bother for such a small user base.
I've managed to get it to behave better by calling finish() on the current activity, and by adding android:launchMode="standard" to all the activity definitions in the manifest. Now, roughly three out of four times the app will exit. The other times, it minimizes, but does not die. When maximized, it resumes to a blank screen. It can be killed manually from the task manager. This can happen whether or not there has been an activity switch, so my previous assertion that an activity switch was necessary to stop it exiting may have been incorrect.
05-28-2013 02:17 PM
I'm sorry, I didn't mean that it couldn't be done, merely that the design of Android is to use the lifecycle methods instead.
There's a great discussion about it here:
Are you running 10.1 builds on your Q? Or something older?
05-29-2013 10:49 AM
You may want to file a bug here:
That way, you can provide your APK for the devs to test against.
05-31-2013 02:34 PM
I have been told that there was a bug in the web page's cookie. If you clear your cookies and try again, it should work.
Let me know if you see an error and we'll get it resolved.