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
Contributor
Posts: 23
Registered: ‎02-22-2011
My Device: Not Specified
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").

 

Developer
Developer
Posts: 1,123
Registered: ‎02-10-2009
My Device: 8130 / 8350 / 9530 / 9550 / 9850 / PlayBook

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.