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
New Developer
astoyan
Posts: 2
Registered: ‎06-13-2008
My Device: Not Specified
Accepted Solution

Add forlder listener to INBOX

Hello.

 

I'm using 8700 device and i'm interested in fixing of the followin below issue for OS 4.0 and higher.

 

Here is a sample from BlackBerry Development Guide of how to add listener to INBOX:

 

Store store = Session.waitForDefaultSession().getStore();
Folder[] folders = store.list(Folder.INBOX);
Folder inbox = folders[0];           
inbox.addFolderListener(listener);

 

At first glance it's quite simple. But it DOESN'T work! Actually, it does work sometimes but only for the first message that fall to inbox. Sometimes. And sometimes it doesn't chatch even the first message.I've tried to add listener to all subfolders recursively but took the same result:

 

Store store = Session.waitForDefaultSession().getStore();
attachToInbox(store.list(Folder.INBOX), listener);

 

private static void attachToInbox(Folder[] folders, FolderListener listener)
{
    for(int i = 0; i < folders.length; ++i)
    {
       folders[i].addFolderListener(listener);
       attachToInbox(folders[i].list(Folder.INBOX), listener);
    }
}

Does anyone the RIM's secret about INBOX? How to cure the bug?

 

Thanks a lot

Please use plain text.
Developer
RexDoug
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Add forlder listener to INBOX

I utilize this API extensively for several applications, and it *does* work (with a few quirks!).

 

I think your issue might be with whatever you are doing after you receive the FolderEvent. Keep in mind that your code is called by the thread in the message application (not your event thread), so you have to be carefull not to block the thread in any way.

 

 

 

 

Please use plain text.
Developer
kzettel
Posts: 120
Registered: ‎07-16-2008
My Device: 9000

Re: Add forlder listener to INBOX

Does this happen on a device or the simulator?  We ran into a similar problem a while back which only affected the simulator and only affected certain versions.  Try using a newer simulator and newer version of MDS and see if it fixes the problem.  
Kurt Zettel | Chief Architect | Metova
www.metova.com
Please use plain text.
Administrator
MSohm
Posts: 14,429
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
My Carrier: Bell

Re: Add forlder listener to INBOX

Please have a look at the following developer knowledge base article.

 

What Is - Application is not notified when new messages arrive
Article Number: DB-00153

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

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
New Developer
astoyan
Posts: 2
Registered: ‎06-13-2008
My Device: Not Specified

Re: Add forlder listener to INBOX

"Solution 1 - Add a FolderListener to the Store" seems to be OK. Thanks a lot!
Please use plain text.