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
arsenk01
Posts: 91
Registered: ‎06-21-2011
My Device: Blackberry Torch 9800

General application exit from anywhere

Hi All,

I know that there are thousand of posts about this,but I want to know is there any way to when application exit from anywhere,I mean no mather what is current screen when end call button is presing I want to exit application.Or I must provide onClose function to every screen?

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

Re: General application exit from anywhere

System.exit(0)

 

...will exit from anywhere in the applicaiton.

 

Developer
arsenk01
Posts: 91
Registered: ‎06-21-2011
My Device: Blackberry Torch 9800

Re: General application exit from anywhere

I know.I just don't want to write onClose,keyDown or keyChar code for each screen.

I asked if there any general way to put some code  and don't bother about writing any more code elsewere.

 

Regards,
Arsen
Developer
peter_strange
Posts: 19,609
Registered: ‎07-14-2008
My Device: Not Specified

Re: General application exit from anywhere

MainScreen will anatomically close the application if you close the last screen in the DisplayStack. 

 

So if you start with one MainScreen and then push another MainScreen , then closing that second MainScreen will correctly display the first MainScreen underneath,  But closing the first MainScreen will exit the app.

 

Alternatively, start on the first MainScreen , when you push the second MainScreen , if you also pop the first MainScreen, the closing the second one will close the app.

 

That said, I think this is bad practice,  I recommend you create a general exit point for your application and make sure it always goes through this.  That way it can tidy up any resources that it needs to. 

Developer
arsenk01
Posts: 91
Registered: ‎06-21-2011
My Device: Blackberry Torch 9800

Re: General application exit from anywhere

Thanks Peter, I did the following in each main screen I overrides the keydown event and in it I check if the end call button is pressed then I call my custom function which will pop screens until the first one and after that exit application.However I don't like this approach.

Regards,
Arsen