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
Highlighted
New Developer
Posts: 1
Registered: ‎09-02-2009
My Device: Not Specified

Running a Java Program in Background

hi,

 

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??

Developer
Posts: 84
Registered: ‎07-17-2008
My Device: Not Specified

Re: Running a Java Program in Background

[ Edited ]

Hi niravthakar,

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.

 

Thanks,

Hemant

Message Edited by hemant on 09-03-2009 01:09 PM
o(-_-)o
Developer
Posts: 242
Registered: ‎01-29-2009
My Device: Not Specified

Re: Running a Java Program in Background

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.

Developer
Posts: 19,631
Registered: ‎07-14-2008
My Device: Not Specified

Re: Running a Java Program in Background

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. 

Contributor
Posts: 12
Registered: ‎05-27-2010
My Device: storm
My Carrier: verizon

Re: Running a Java Program in Background

Thanks 

 

this:

 

UiApplication.getUiApplication().requestBackground();

 

solves a problem i had.