How to setup alternate entry point in Blackberry application?
Solution 1:
Try logging the value of args and (if not null) args[0] to see what's actually being passed into main(). It's likely a problem with your compilation process where the background module is not passing an argument (or not passing the correct value).
Also, try saving off your EntryPointForApplication instance into a static variable so that it maintains a reference (isn't garbage collected) and so that if the icon is clicked again from the home screen while it's already running, you don't start multiple instances of your app. For example:
class EntryPointForApplication extends UiApplication {
private static EntryPointForApplication theApp;
public EntryPointForApplication() {
GUIApplication scr = new GUIApplication();
pushScreen(scr);
}
public static void main(String[] args) {
if ( args != null && args.length > 0 && args[0].equals("background1") ){
// Keep this instance around for rendering
// Notification dialogs.
BackgroundApplication backApp=new BackgroundApplication();
backApp.setupBackgroundApplication();
backApp.enterEventDispatcher();
} else {
if (theApp == null) {
// Start a new app instance for GUI operations.
theApp = new EntryPointForApplication();
theApp.enterEventDispatcher();
}
}
}
}