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: 42
Registered: ‎12-04-2008
My Device: Not Specified
Accepted Solution

Catch application close event?

How can I catch the application close event? Anyone can tell me the api to use? Thanks in advance.
Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Catch application close event?

[ Edited ]

Try Application.deactivate() - this is called when the app is moved to background - not the same thing but might be useful.

 

Message Edited by RexDoug on 01-05-2009 10:41 PM
Developer
Posts: 42
Registered: ‎12-04-2008
My Device: Not Specified

Re: Catch application close event?

Sorry,I just want to catch the application closing event and do something before.
Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Catch application close event?

Don't think there is any way to do this.

 

When is the application ending that you didn't explicitly end it?

 

 

 

 

Developer
Posts: 42
Registered: ‎12-04-2008
My Device: Not Specified

Re: Catch application close event?

but how can I remove a phoneListener? if not, the listener will always exist although the applictation is shut down.
Developer
Posts: 5,339
Registered: ‎09-20-2008
My Device: ***
My Carrier: ***

Re: Catch application close event?

Create your own functionality to clean up when the application  is going to exit.

 

Do not call System.exit(0) directly in your application.

 

Implement a method that does all clean-up actions and invokes System.exit(0) after all.

 

And call only this method when you want to exit.

 

 

Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Catch application close event?

AND....don't forget to put your "enterEventDispatcher()" in a try/catch/finally block so that you clean up after an unhandled exception.

 

Smiley Happy

 

Developer
Posts: 5,339
Registered: ‎09-20-2008
My Device: ***
My Carrier: ***

Re: Catch application close event?

finally block

 

try {

app.enterEventDispatcher();   

} finally {

 

}

 

not executed if you exit from your application via System.exit(0);