View Single Post
  (#17 (permalink)) Old
CELITE Offline
Thumbs Must Hurt
 
Posts: 135
Join Date: Dec 2005
Model: 8310
Carrier: Rogers
Default 07-23-2008, 05:59 PM

Quote:
Originally Posted by Aiwa View Post
even though you're not trying to be a jerk you were.
this is a forum to help people and with your post you didn't help ANYONE, just created one more message to be left in this post...

don't even come talk about my post, i'm trying to get my help here
admins should ban this kind of people that think they are smart, but can't help anyone...
step out then and leave for the nice (and smart) people to help me, because obviously you can only say bad stuff about things.

Hey hey, no need to get angry. I'm trying to help you out here! I simply deduced from your posts about those compiler issues that there might be some basics you're missing.

All I'm saying is without the fundamentals, it will be difficult if not impossible for you to understand what's going on!

Here are some links that can get you started:
javabeginner.com | Table of contents -- An excellent java fundamentals tutorial

Livelink - Redirection - you can get at many useful blackberry articles here

For reference, here is some code that will do what you're trying to do with a step by step explanation:

Code:
class FolderListenerMain extends UiApplication {
   
    private MainScreen  _mainScreen;
    private LabelField  _notifyField;
    
    public static void main( String[] args ) {
        
        // Create the UiApplication object and register it with the system
        // to start receiving UI events.
        FolderListenerMain app = new FolderListenerMain();
        app.enterEventDispatcher();
    }
    
    FolderListenerMain() {   
    
        // Create a new thread so the event dispatch thread doesn't block
        // when waitForDefaultSession() is invoked.
        Thread loadStoreThread = new Thread( new Runnable() {
            public void run() {
                
                // The mail store
                Store s = null;
                try {
                    
                    // Get the default mail session (if corporate this would be 
                    // a session associated with a BES mail servicebook record)
                    s = Session.waitForDefaultSession().getStore();
                    
                    if ( s != null ) {
                        
                        // Register the folder listener with the Store
                        s.addFolderListener( new FolderListener() {
                            
                            // Called when any message is added to the store
                            public void messagesAdded( FolderEvent e ) {
                                
                                Message m = e.getMessage();
                                if ( m != null && m.isInbound() ) {
                                    
                                    // Have to make sure this invoke later actually ends up on
                                    // our application's event queue. Simply calling UiApplication.getUiApplication
                                    // is not sufficient because the application we get back is not our own.
                                    FolderListenerMain.this.invokeLater( new Runnable() {
                                        public void run() {
                                            _notifyField.setText( "Message Received" );
                                        }
                                    });
                                }
                            }
                            
                            // Called when any message is removed from the store
                            public void messagesRemoved( FolderEvent e ) {
                                FolderListenerMain.this.invokeLater( new Runnable() {
                                    public void run() {
                                        _notifyField.setText( "Message Deleted" );
                                    }
                                });
                            }
                        });
                    }
                }
                catch ( Exception e ) {
                    ; // It would probably be good to catch the specific exception rather than a general one
                }
            }
        });
        
        _mainScreen = new MainScreen();
        _mainScreen.setTitle( "FolderListener Test" );
        _notifyField = new LabelField( "Waiting for message..." );
        _mainScreen.add( _notifyField );
        pushScreen( _mainScreen );
        
        loadStoreThread.start();
    }
}
I hope this helps! (Maybe I'm not that bad a guy? :P)

Last edited by CELITE : 07-23-2008 at 06:30 PM.
   
Reply With Quote