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

Adobe AIR Development

Reply
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10

QNX About To Quit

I do not see any events that would message an application that the user is about to quit the application.  Obviously, if I have a quit button, I can trap that, but other than deactivate event, if the user select the close button when the app is minimized, there is no way to know that is about to close down the application.  Yes, application state should be saved when deactived or low memory, but in the case where the application may have an active connection to another app or service, it would be nice to properly cleanup and close those connections.  I did not see anything in the QNXApplication class.  Wondering if someone has tripped over something like this.

Please use plain text.
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

Re: QNX About To Quit

Best I can offer is what I wrote about the PlayBook application lifecycle after experimenting with various events. 

 

In short, it looks to me like responding to DEACTIVATE with quick, blocking calls to save critical state, is the best thing you can do for now. There's an EXITING event that doesn't appear useful right now.

 

If you have active connections that can't be closed with a blocking call (e.g. you're talking to an SMTP server and you'd like to send QUIT and wait for the server to close the connection, to be "clean"), you have no choice but to try to do it asynchronously and hope that things happen quickly enough that you get done before the user manages to swipe up again or click the X widget.  And that may not help if the reason you got deactivated was low battery or memory (so subscribe to those events if you care).

 

If you were planning to save state externally (over the network) I think you would have little choice but to save it locally as a blocking call (to guarantee that it succeeds) followed by starting an attempt to save again remotely, knowing that attempt may be aborted in the middle as the app closes.

 

A comment on "clean" shutdown... I expect we can count on QNX to clean up much better after our app than most other OSes would be able to.  I don't feel uncomfortable with the idea of having lots of open files, sockets, etc when I go down, provided I've flushed whatever I can flush.


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10

Re: QNX About To Quit

Thanks.  Connection is to a pub/sub server.  Seems to clean up OK without a proper disconnect, just rather be cleaner.  Hopefull a later SDK will have such an event.

Please use plain text.