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
jeyaprakash
Posts: 33
Registered: ‎07-16-2008
My Device: bold
Accepted Solution

Add and Remove Folder Listner to store

I developing an application with Folderlistner api.. i can get all mails from my store i got 2 problems in my application

 

I cant quit folderlistner. am using

removelistner method while calling exit (system.exit) after tat my application processing all emails for example my application deleting all emails from my store. how to remove folderlistner from store 

 

 when restart my application it processing emails once again i mean 2 listners working in same time not only 2

 For every restart another one listner shoud added 

 

 how can i solve this problems? 

 

 to adding listner 

mystore= session.getStore(); mystore.addFolderListener(this);

 

to removeing llistner while calling system.exit(0) 

 

mystore.removeFolderListener(this); mystore=null;

 

 

 


 

Please use plain text.
Developer
yosoh
Posts: 213
Registered: ‎07-18-2008
My Device: Not Specified

Re: Add and Remove Folder Listner to store

take a look at this article which exactly does what you are looking for:

 

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800451/800783/How_To_...

 

 

regards,

 

yosoh 

--------------------------------------------------
problemSolved() ? kudosPlease():kudosPlease();
Please use plain text.
New Developer
jeyaprakash
Posts: 33
Registered: ‎07-16-2008
My Device: bold

Re: Add and Remove Folder Listner to store

but my application don have alternate entry points its just a background application with simple ui when user click application icon my application comes foreground how can i get singleten instence
Please use plain text.
Developer
yosoh
Posts: 213
Registered: ‎07-18-2008
My Device: Not Specified

Re: Add and Remove Folder Listner to store

To create a singleton instance you dont need an alternate entry point. I was referrring you to this part of the code and not the complete application. Just implement the following part in your application and no need to do alternate entry point settings.

private FolderListenerGUI folderListenerGUI = null;

//Long value: com.samples.folderListener

public static final long RTSID_MY_APP = 0x7451402f595f81a5L;



public FolderListenerApp()

{

try

{

//Get the store from the default instance.

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

//Add the folder listener to the store.

store.addFolderListener(this);

}

catch (Exception e)

{

System.out.println(e.toString());

}

}



//Returns an instance of the running FolderListenerApp.

public static FolderListenerApp waitForSingleton()

{

//Ensure this is a singleton instance.



//Open the RuntimeStore.

RuntimeStore store = RuntimeStore.getRuntimeStore();

//Obtain the reference of FolderListenerApp.

Object obj = store.get(RTSID_MY_APP);



//If obj is null, there is no current reference

//to FolderListenerApp. Start a new instance

// of FolderListenerApp if one is not running.

if (obj == null)

{

//Store a reference to this instance in the RuntimeStore.

store.put(RTSID_MY_APP, new FolderListenerApp());



return (FolderListenerApp)store.get(RTSID_MY_APP);

} else

{

return (FolderListenerApp)obj;

}

}

 

regards,

 

yosoh

--------------------------------------------------
problemSolved() ? kudosPlease():kudosPlease();
Please use plain text.
New Developer
jeyaprakash
Posts: 33
Registered: ‎07-16-2008
My Device: bold

Re: Add and Remove Folder Listner to store

Thank u man got Fixed...
Please use plain text.