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
robybd
Posts: 216
Registered: ‎09-11-2008
My Device: 9000(Bold)
Accepted Solution

SMS Class cast

 

Hello,

 

My app. adds to the SMS folder a new menu item which the user can select and it will read the address of the highlighted SMS and allow the user to reply\edit\fwd the SMS.

I've managed to add the menu item, but when my app. tries to read the SMS address it fails (i tried to do cast for Datagram class)

Does anyone knows how can i get the SMS address?

 

Just to clarify myself, i'm using the API of "ApplicationMenuItem" and when the user choose my item, my app. enetrs the "run" function

and there i try to read the address.

 

Thanks.

Developer
Posts: 5,339
Registered: ‎09-20-2008
My Device: ***
My Carrier: ***

Re: SMS Class cast

When you add a menu item to an existing application, then when you have invoked your menu item then a context object has been passed to your code.

 

Let's assume contextObject is that context object instance.

 

call the following construction to realize the full qualified name of this context object class:

 

System.out.println(contextObject.getClass().getName());

 

When you have realized the contextObject class inspect its methods via javadocs and act accordingly.

Developer
robybd
Posts: 216
Registered: ‎09-11-2008
My Device: 9000(Bold)

Re: SMS Class cast

Hi,

I tried your suggestion and the class name is: net.rim.device.cldc.io.sms.TextMessageImpl

However i couldn't find it in the RIM JDE at all, do you have an idea to which class i should try to cast it?

Thanks.

 

Developer
Posts: 5,339
Registered: ‎09-20-2008
My Device: ***
My Carrier: ***

Re: SMS Class cast

This context object is an instalnce of implementation of


javax.wireless.messaging.TextMesssage

 

interface.

 

This interface extends 

 

javax.wireless.messaging.Message

 

interface.

 

You can do the following:

 

Message messageObject = (Message) contextObject;

String address =  messageObject.getAddress();

 

that's it.