04-15-2011 04:55 AM
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").
Solved! Go to Solution.
04-15-2011 10:00 AM
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.