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

Java Development

Reply
Developer
Posts: 23
Registered: ‎08-06-2008
My Device: Not Specified

Is there an equivalent to Application.onClose() event ?

Since the Screen's onClose() is just that - screen's - does not quite work for an application in the whole.

deactivate() does not even get a chance to run on terminate.

Is there a solid way to figure out if your application is closing to run some cleanup code?

 

Thanks,

Nik

 

Developer
Posts: 17,012
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Is there an equivalent to Application.onClose() event ?

onClose terminates the application if there is no other screen to display. overwrite it on the last screen to control its behavior.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 23
Registered: ‎08-06-2008
My Device: Not Specified

Re: Is there an equivalent to Application.onClose() event ?

That we knew, thanks. I was asking if there is such event for an application, not screen.
Developer
Posts: 17,012
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Is there an equivalent to Application.onClose() event ?

why should an application exit without you controlling it?
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Highlighted
Developer
Posts: 23
Registered: ‎08-06-2008
My Device: Not Specified

Re: Is there an equivalent to Application.onClose() event ?

There are many reasons why would application terminate, including system initiated shutdown. Hooking up to the active screen is not solid since there may be many screens controlled by an application, and you'd need to add that close() to all of them. Does not seem overly convenient.

BB IS an event driven architecture so there should basically be events for everything. Or at least I believe so. 

 

Thanks,

Nikolay

 

Developer
Posts: 17,012
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Is there an equivalent to Application.onClose() event ?

you may get an event for system.exit, but it is not of much use as the jvm is terminated.
system initiated shutdown can be checked using a system listener.
you can overwrite methods for all your screens by subclassing mainscreen and using this screen in your app. or using managers and only a single mainscreen.

if you want processing on shutdown you have to control the shutdown.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 1,474
Registered: ‎04-14-2009
My Device: Not Specified

Re: Is there an equivalent to Application.onClose() event ?

System.exit, on BlackBerry, terminates only the current application. It does not terminate the JVM (have a look at Javadocs).
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Is there an equivalent to Application.onClose() event ?

I'm guessing the OP wants a method or listener they can implement that will be called regardless of how the Application terminates.  I am not aware of anyway to do this.