thx doug...... I think you are right. I moved the listener into my main App and it suddenly works... But now I'm facing different problem. When I tested and run it in 9530 simulator, it works fine. But when I deployed on actual device I got java.lang.NullPointerException
Here is my main application code :
Code:
public class App extends UiApplication implements FolderListener {
private MailBoxScreen _main;
public static void main(String[] args) {
App instance = new App();
instance.enterEventDispatcher();
}
/** Creates a new instance of App */
public App() {
_main = new MailBoxScreen(this);
pushScreen(_main);
}
public void messagesAdded(FolderEvent e) {
//TODO: append to the vector
final Message incoming = e.getMessage();
if (incoming != null) {
try {
while (App.this == null) {
try {
Thread.sleep(1000);
} catch (InterruptedException ex) {
ex.printStackTrace();
}
}
App.this.invokeLater(new Runnable() {
public void run() {
//Dialog.alert("1 new mail received");
LED.setState(LED.STATE_BLINKING);
Alert.startVibrate(2000);
MailBoxScreen.getMailListInstance().refreshMail(incoming);
}
});
} catch (NullPointerException ex) {
}
}
}
I also has surround each code on method that called from the main application with Exception. Still cannot find where i got the NullPointerException
