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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
Contributor
hrnt
Posts: 23
Registered: ‎02-22-2011
Accepted Solution

Robust "Always on" applications

I am working on a program that needs to be running on the background constantly. At the moment I have something like this (app is a UiApplication)

 

"app startup", alternative entry point that stores itself to RuntimeStore and enters the event dispatcher. This is started automatically on startup. "app startup" icon is not visible in home screen.

 

"app", main entry point. Retrieves the "always running" instance from RuntimeStore and adds a pushScreen to its event queue (with invokeLater). This entry point is visible in home screen.

 

When the last screen of the UI is closed, the application does requestBackground() and does not terminate.

 

 Usually this works pretty well. However, what should I do if the "app startup" has crashed or has not started? (Either the RuntimeStore contains null, or the app object is not running (!app.isAlive()) If my main entry point enters the event dispatcher, I cannot use its icon anymore to start the application (I get "App is already running").

 

Please use plain text.
Developer
Developer
CMY
Posts: 1,117
Registered: ‎02-10-2009
My Carrier: Verizon

Re: Robust "Always on" applications

If your background app stops or terminates, you can use the ApplicationManager to start it back. You would need to check for this in your user started app, and if there is no instance of the background app, then create it and wait for it to start before preceding to load. I've never actually tried to relaunch a background app,  but I have launched various entry points of the same app in this matter.

Please use plain text.