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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Highlighted
Contributor
Posts: 16
Registered: ‎07-28-2010
My Device: Bold 9700
My Carrier: Vodafone
Accepted Solution

PersistentObject and SendListener Problem

I have registered a SendListener to intercept outbound emails. When my handler is called I would like to access my application settings stored in PersistentObject to determine what I should be doing in my sendMessage Handler. 

 

The problem is I can't access any information set in my application. I suspect this is because my sendMessage Handler is running in the context of the mail application. 

 

What design do I need to follow to access my persistent store from a handler like this?

 

Thanks

John.

 

// John Goodyear
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: PersistentObject and SendListener Problem

I must admit I have not actually tested this recently myself, but AFAIK you should be able to access your Persistent Objects - assuming your are running using your own code and Persistent Object classes, the context should not matter.

 

Can you describe the issue when you attempt to access the information?  If your objects seem to be 'null' then I would suspect you are using static references.  static variables are specific to a context, so your listener will see different static variables to your application.

 

The reason I have not tested this recently is that normal practice for listeners is to context switch to your own Application, and the usual way to do this is via a GlobalEvent

http://supportforums.blackberry.com/t5/Java-Development/Global-Events-and-Global-Event-Listeners/ta-...

 

Contributor
Posts: 16
Registered: ‎07-28-2010
My Device: Bold 9700
My Carrier: Vodafone

Re: PersistentObject and SendListener Problem

Thanks Peter,

 

My application wraps its settings in a class, the settings are stored inside a Hash table defined as follows:

 

static Hashtable settingsTable;

 

You suspect the static declaration is the problem? 

 

I'd not considered the context switch - I will investigate that too. 

 

// John Goodyear
Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: PersistentObject and SendListener Problem

static variables are not shared between contexts, maybe that is related to your issue.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Contributor
Posts: 16
Registered: ‎07-28-2010
My Device: Bold 9700
My Carrier: Vodafone

Re: PersistentObject and SendListener Problem

Removing static has fixed the problem - thanks for your quick replies and solution everyone. 

// John Goodyear