Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Android™ Runtime Development

Reply
New Contributor
graham_h
Posts: 5
Registered: ‎06-30-2010
My Device: Nokia N950
My Carrier: n/a

System.exit() hangs app

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?

 

Graham.

Please use plain text.
BlackBerry Development Advisor (Retired)
jjasmann
Posts: 264
Registered: ‎01-08-2013
My Device: BlackBerry 10 Dev Alpha B
My Carrier: Bell

Re: System.exit() hangs app

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?

 

    Justin

Justin Jasmann | Android Application Development Consultant
Developer Relations
developer.blackberry.com
Please use plain text.
New Contributor
graham_h
Posts: 5
Registered: ‎06-30-2010
My Device: Nokia N950
My Carrier: n/a

Re: System.exit() hangs app

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.

 

Graham.

Please use plain text.
BlackBerry Development Advisor (Retired)
jjasmann
Posts: 264
Registered: ‎01-08-2013
My Device: BlackBerry 10 Dev Alpha B
My Carrier: Bell

Re: System.exit() hangs app

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:

http://stackoverflow.com/questions/2033914/quitting-an-application-is-that-frowned-upon/2632649#2632...

 

Are you running 10.1 builds on your Q? Or something older?

 

    Justin

Justin Jasmann | Android Application Development Consultant
Developer Relations
developer.blackberry.com
Please use plain text.
New Contributor
graham_h
Posts: 5
Registered: ‎06-30-2010
My Device: Nokia N950
My Carrier: n/a

Re: System.exit() hangs app

As I say, using Activity.finish() isn't helping.  Something odd is happening somewhere.

 

It's 10.1.0.273.

Please use plain text.
BlackBerry Development Advisor (Retired)
jjasmann
Posts: 264
Registered: ‎01-08-2013
My Device: BlackBerry 10 Dev Alpha B
My Carrier: Bell

Re: System.exit() hangs app

You may want to file a bug here:

https://www.blackberry.com/jira/secure/Dashboard.jspa

 

That way, you can provide your APK for the devs to test against.

 

    Justin

Justin Jasmann | Android Application Development Consultant
Developer Relations
developer.blackberry.com
Please use plain text.
New Contributor
graham_h
Posts: 5
Registered: ‎06-30-2010
My Device: Nokia N950
My Carrier: n/a

Re: System.exit() hangs app

I do want to... but that page won't open...

Please use plain text.
BlackBerry Development Advisor (Retired)
jjasmann
Posts: 264
Registered: ‎01-08-2013
My Device: BlackBerry 10 Dev Alpha B
My Carrier: Bell

Re: System.exit() hangs app

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.

 

    Justin

Justin Jasmann | Android Application Development Consultant
Developer Relations
developer.blackberry.com
Please use plain text.