11-20-2009 05:46 PM
Currently my application has a GUI thread and a background thread that listens to the server. Right now, I'm lauching the server listener from the GUI thread(and then send the GUI app to the background). However my problem is that if the user closes the GUI application, the server thread stops.
I would like the server thread to keep going even if the user exit the GUI, it that possible for blackberry? For example to override the shutdownApp() method?
Solved! Go to Solution.
11-20-2009 05:50 PM
Is this a Midlet or a standard RIM application?
11-20-2009 05:51 PM
Thanks for the quick reply! It's a RIM application
11-20-2009 06:09 PM - last edited on 11-20-2009 07:26 PM
In this situation, I would override close() on your 'home' screen so that it just calls
UiApplication.getUiApplication().requestbackground
Then your app does not stop, but as far as the user is concerned, it has gone away.
Also change places that deliberately call System,exit() to do the same.
You can use things like onObscured() and onExposed() on the Screens, or activate() and deactivate() in the Application to detect movement to and from background and take whatever action is appropriate, for example to stop any auto-updating on the Screen that you are doing which is not needed if no one is watching the screen!
If you call System.exit(..), or it gets called for you when you close your last MainScreen, you have no choice - your Threads will be stopped. There is nothing you can do about it, and the only options to work around this are much more painful that making sure you don't deliberately or inadvertently call System.exit().
I'm confused by your suggestion you have a GUI Thread? Do you really mean a GUI Thread that you create? You don't usually need one of these.
Also, just noted, this is your first Thread... Welcome!
11-20-2009 06:21 PM
Thanks Peter This is a great forum btw, I've been lurking here a lot when I was starting the application![]()
"I'm confused by your suggestion you have a GUI Thread? Do you really mean a GUI Thread that you create? You don't usually need one of these."
Does GUI thread mean something else? I just meant the screens and everyhing I create for the app. What do you mean by not needing one of these?
And I'll try your suggestion and see how it goes.
11-20-2009 06:26 PM
"Does GUI thread mean something else?". A Thread is something that you create with a Runnable and then start.
The GUI processing is usually event driven. But you can have a Thread that does things like update clocks on Screens each minute. Hope that is clearer. Sounds like you don't have a special GUI Thread to do that sort of thing.
Hope my suggestions work for you.
11-20-2009 08:36 PM
Got it. It works great. Thanks!