01-18-2010 12:56 AM
Hi
We have a UI Application. The application has been set to Auto run on Startup and as a System Module.
The application has a folder listener which checks for any new emails.
When we start the UI application by clicking on the app icon it seems that the multiple instance of the application is being created. Because of this when we send an email to the application it is receiving email multiple times. Sometimes single, twice and sometimes even five times.
public class MyApplication extends UiApplication implements FolderListener,
SystemListener, GlobalEventListener {
// Boot
public static void main(String[] args) {
if (args != null && args.length > 0 && args[0].equals("gui")) {
// code to initialize the app
fromService = false;
// register the notification
Notification n = new Notification();
n.registerNotificationObjects();
Utilities.writeLog(GUID, "MyApplication GUI Starting up");
MyApplication service = new MyApplication();
service.enterEventDispatcher();
} else {
Utilities.writeLog(GUID, "OnBoardV2 Service Starting up");
MyApplication service = new MyApplication();
service.enterEventDispatcher();
}
}
public void messagesAdded(FolderEvent e) {
/// Receive messages
}
}
Any help in this regard will be apreciated!
Thanks
Solved! Go to Solution.
01-18-2010 01:57 AM - last edited on 01-18-2010 01:58 AM
Hi
I forgot to mention that we also implement SystemListener and application is also started on device start up. Could this be the reason ?
But then at times it responds only once to an email.
01-18-2010 02:37 AM
I dont know if that is your whole code, but if you register your app as a folder listener ever time it is invoked then you are registering multiple listeners. The listener does not get removed cause your app closes, you have to explicitly remove the listener. You need to either put the listener in its own class and only register on startup or find a way to chek if the listener is already registered every time the app is invoked.
01-18-2010 04:26 AM
Hi
We just found out that the application was being registered as a folder listener twice, once when the application starts on the device start up and once again on starting UI by clicking icon.
We have now removed the code to register application as a folder listener on UI startup.
We understand that this has resulted in application receiving email twice. But still we could not figure out how it was receiving emails 3, 4, 5 times?
Any clue on this?
Thanks
01-18-2010 04:31 AM
Each time someone exited and restarted the application a new listener was added?
If the problem has been resolved by your change I would almost guarantee that was the cause.
01-18-2010 04:36 AM
Yeah. It looks like the problem has been solved by that change.
Thanks for the help.