Alternate entry point run 2 times when acces my app on Blackberry?
I have an alternate entry point set to auto-run to push a dialog开发者_如何学C with a particular time; It runs successfully. The alternate entry point will auto-run when the device is on, as expected. However, when I run my app interactively, the dialog shows twice. How can I prevent this?
public static void main(String[] args) {
if ( args != null && args.length > 0 && args[0].equals("autorun")) {
MyApp theApp = new MyApp();
theApp.enterEventDispatcher();
} else {
MyApp theApp = new MyApp();
theApp.pushScreen(new MyScreen());
theApp.enterEventDispatcher();
}
}
public MyApp() {
this.addRealtimeClockListener(this);
}
public void clockUpdated() {
checkTimetoPushDialog();
}
So, if I understand this correctly, clockUpdated is invoked as part of the Realtime Clock listener. The listener is added when MyApp is constructed, and MyApp is constructed for both the foreground and background app.
So it's not so surprising that the dialog is pushed for both the foreground and background app.
If you don't want to see the dialog when the user starts the app, avoid adding the listener when you are not an auto-start process.
精彩评论