11-12-2010 05:59 AM
How to set the app to both autostart & run in the background?
The autostart part is already done, by checking the "Auto-run on startup" checkbox.
But what about the background part?
I put Application.getApplication().requestBackground
What I mean is: every time the BB turned on, the app will also automatically run in the background (fetching data periodically). And if the app icon is clicked, then it will be shown.
11-12-2010 06:25 AM
You can use alternate entry point of main() method. From the argument you can decide whether to run in background at startup or show application in normal way.
--------------------------------------------------
feel free to press the kudos button on the left side to thank the user that helped you.
please mark posts as solved if you found a solution
11-12-2010 06:58 AM
Hmm... what should I use as the argument?
11-12-2010 07:25 AM
Check out this for more info. Maybe you find it helpful
11-13-2010 01:09 AM
How do I get the ID?
Should I assign it manually?
11-13-2010 10:28 AM
requestBackground(); is a one off statement, it does not mean your application will stay in the background. So the combination you have in place should work. Since you are starting the Application at start-up time and you want this to be displayed, you should be starting a UiApplication. Since clicking on the icon will just cause the existing app to be moved to the foreground, you should make sure that there is a screen ready to display. To make sure that the app is not closed, you should make sure that it always does requestBackground(), rather than System.exit(0). But all thes is relatively straightforward.
There is no need to use an Alternate Entry to meet this requirement.
11-13-2010 11:08 AM
RuntimeStore appReg = RuntimeStore.getRuntimeStore();
synchronized(appReg){
if (appReg.get(ID) == null) {
appReg.put(ID, new Application(...));
}
Application MyApp = (Application)appReg.waitFor(ID);
}
What to fill the blanks with?
11-13-2010 12:26 PM - edited 11-13-2010 01:03 PM
Anyway, now this is what I have in the app constructor:
When the app icon is clicked, it won't show up.
Hmm.... ![]()