View Single Post
  (#3 (permalink)) Old
rhen.sn Offline
New Member
 
Posts: 3
Join Date: Jun 2009
Model: 8900
PIN: N/A
Carrier: XL
Default 07-06-2009, 03:17 AM

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
   
Reply With Quote