If you’ve ever developed a Blackberry app that has an Alternate Entry Point and runs in the background, you’re familiar with this typical scenario in your main application class (or something very much like it):
public static void main(String args[]) {
if (args.length>0 && args[0].equals("autostartup"))
{
MyApp app = new MyApp();
app.registerPushApplication();
app.enterEventDispatcher();
}
else
{
new MyApp().showGUI();
}
}
But wait a minute… how come I can ** still ** see my application’s autostart instance in the “Switch Applications” dialog?!?
This isn’t what I wanted.
Here’s the additional “secret sauce” you need:
First, declare a private global boolean in your main application class. I call mine (usually) _acceptsForeground and set it to false initially.
Next, in your main application class handle the UIApplication.acceptsForeground callback and code it like this:
protected boolean acceptsForeground() {
return _acceptsForeground;
}
Finally, in your showGUI() method (or whatever you call your analogous implementation) you need to add the following two (2) lines of code at the beginning of the method:
_acceptsForeground = true;
UiApplication.getUiApplication.requestForeground();
And that’s that. No longer will your application’s autostart instance appear in your task switcher.
Like this:
Like Loading...