09-02-2009 08:49 PM
I am developing a SMS application which sends a preconfigured message to the specified number. I have a GUI interface by which a user can start and stop the sms sending program. If the user selects stop radio button the background program should terminate.
I have a background program written by me.I have created the GUI.
This background program should continue to run even if the GUI is closed and start option is selected.
How can i invoke it in background service from the GUI. and similarly how can i terminate it from the GUI??
09-03-2009 03:38 AM - edited 09-03-2009 03:39 AM
Are you asking this question from BB point of view?. FYI, This is not the correct forum to ask Java related questions if they are not related to BB application
Anyway, for you questions, you could have some configuration file saved some where on file system(even in case of BB u can save it on SDCard/device memory)
That configuration file should have some flag in it, which will decide whether to start/stop the background process.
What you need to do is just from you GUI app, when you do Start/Stop of background app, update the associated flag in configuration file.
Your background app should read this flag periodacally, and if flag is Stop, then terminated itself.
09-03-2009 08:43 AM
Sounds like you're working on a SMS spam application. ;-)
You can send an application to the background by doing something like UIApplication.getUIapplication().requestBackground
The code which will send the SMS should run in a seperate thread.
09-03-2009 10:53 AM
Agree with pfiffi78.
And since your UI will actually start the background SMS Thread, it will have a handle on it and it can call a 'stop' method directly - which is a lot easier than having some persisted flag.