Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 238
Registered: ‎12-26-2010
My Device: BlackBerry Z10
My Carrier: Telus

Notify an Application via PIN Message

Hi folks, I am trying to notify an application when it detects changes in messages folder

 

Class BackgroundProcess extends Application implements FolderListener
{

public BackgroundProcess()
{
        try
        {
            Store store = Session.waitForDefaultSession().getStore();
            store.addFolderListener(this);
        }
        catch(NoSuchServiceException ex)
        {
            Dialog.alert("NoSUCHSERVICEEXCEPTION");
        }

}


public void messagesRemoved(FolderEvent e)
{
       ........
}
    
public void messagesAdded(FolderEvent e)
 {
        Dialog.alert("Messages Added");
 }

 

 

 

As you can see, I added the FolderListener to the entire store.

 

The messagesAdded() method was triggered when the user sends an email/PIN message, but It wasn't triggered when the user receives an email/PIN message.

 

What might have been possibly wrong in my code? Shouldnt the messagesAdded() method run when theres a message added to the folder (since I added the FolderListener to the entire store which should include inbox and outbox)?

 

Please guide me on this, thanks folks..

www.jackdevora.com
Developer
Posts: 62
Registered: ‎10-29-2008
My Device: 9800
My Carrier: Rogers

Re: Notify an Application via PIN Message

hrmm... I've never listened for PIN messages, but I do know that for SMS messages you actually have to open up a port to listen for this messages... is this perhaps how the PIN messages work as well?

 

Just a thought

Highlighted
Regular Contributor
Posts: 77
Registered: ‎09-19-2008
My Device: Blackberry 8320
My Carrier: Airtel India

Re: Notify an Application via PIN Message

I am getting notification on incoming PIN message, the only difference in code is I have used

getDefaultInstance() instead of waitForDefaultSession(),

 

i.e.

Store store = Session.getDefaultInstance().getStore() ;

 

 

See whether this helps!

 

Regular Contributor
Posts: 77
Registered: ‎09-19-2008
My Device: Blackberry 8320
My Carrier: Airtel India

Re: Notify an Application via PIN Message

Additionally, ensure incoming PIN messages are going to default Inbox folder, if not then you have add folder listener to all the available folders.

 

Read this article for more details,

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800698/What_Is...

Developer
Posts: 238
Registered: ‎12-26-2010
My Device: BlackBerry Z10
My Carrier: Telus

Re: Notify an Application via PIN Message

Thanks for the replies.

I had stumbled upon the link you posted above, I used the first solution which was the simplest. Adding the FolderListener to the Store, but still not getting the notification, Maybe I messed up somewhere else. Thanks for the help ManikandanP and mickel..
www.jackdevora.com