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
arindamhit
Posts: 271
Registered: ‎12-24-2010
My Device: BlackBerry 10

How to kill the application?

Hi, 

In my app, i am using BBM and sending  some messages using BBM. So when i am sending, it will open the chat window from my app. And using that BBM Chat window i will send the message. But after message went successfully, i want to close the app. Using System.exit(), it is not working. if in the chat window i will press back button it will also closing the app when i am using System.exit(). So is there any way to kill the app??

i tried with below code :

public void killApp() {
	      System.exit(0);
	}

 but it is not working for me.

Developer
simon_hain
Posts: 16,364
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: How to kill the application?

System.exit usually terminates the application, what exactly does not work in your case?
----------------------------------------------------------
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
arindamhit
Posts: 271
Registered: ‎12-24-2010
My Device: BlackBerry 10

Re: How to kill the application?

In my case when i am seding a message, i am writing the below code:

if(field == btnSendList)
{   
              platformContext.getUIService().startBBMChat(tbsfMsg.getText().toString());
	System.exit(0);
}

 So when it will open the BBM chat window, it will call System.exit also. So if when BBM chat window is showing and user has been click the back button, the whole application is closing, instead of coming to the previous screen. I hope you understand what i am saying.

Developer
simon_hain
Posts: 16,364
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: How to kill the application?

and this works? or it doesn't work? i don't understand what the problem is :smileyhappy:
----------------------------------------------------------
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
arindamhit
Posts: 271
Registered: ‎12-24-2010
My Device: BlackBerry 10

Re: How to kill the application?

It will close my app obvious but in the midway. when the chat window start, that time itself app is destroying. So if will not send the message(I mean you are in the chat window which is BBM Chat window), and press the back button, it will exit from the app. Because already System.exit() has been run. 

 

platformContext.getUIService().startBBMChat(tbsfMsg.getText().toString());

 

this code only help me to open the BBM chat window.

New Developer
enamur_rashid
Posts: 14
Registered: ‎01-31-2011
My Device: Simulator

Re: How to kill the application?

what if you use 

if(field == btnSendList)
{           platformContext.getUIService().startBBMChat(tbsfMsg.getText().toString());
	close();
}

 If there is no application screen on the display stack then close() apparently work as exit the application

----------------------------------------------------------
Please press the like button on the right side to thank the person who helped you.
Please mark the post as solved if you found it as solution.
Developer
simon_hain
Posts: 16,364
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: How to kill the application?

if i understand your problem correctly the bbm message is not sent as the application is already killed and somehow needed for that.
you can set a kill flag and call system.exit on the activate method, this will ensure that the application is running while the chat window is open and closes when the user returns to your app.
----------------------------------------------------------
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
Contributor
abhinav_saxena
Posts: 19
Registered: ‎04-20-2011
My Device: BlackBerry Pearl

Re: How to kill the application?

[ Edited ]

Why kill application? just call UiApplication.getUiApplication().requestBackground();

I should never kill my application if I want a service keep running.

Or you can start this chat screen from another application (which will open chat screen and close main application), call this application from your main application using CodModule and keep your second application running.

//--

You can also use GlobalEvent to signal your application to close.. in the EventOccured method.