BlackBerry Forums Support Community

Closed Thread
LinkBack Thread Tools
Old 06-24-2009, 11:01 PM   #1 (permalink)
New Member
Join Date: Jan 2008
Model: 8310
Carrier: AT&T
Posts: 1
Post Thanks: 0
Thanked 0 Times in 0 Posts
Exclamation Help with adding menu item to compose sms message

Please Login to Remove!

I'm trying to add a simple menu item to the address book so you will be able to app key click on a contact then the program would go and execute some code to go into the compose screen to send an sms text message to the contact you app key clicked on.

Here is a bit of the code:
public Object run(Object context) {
        if (context instanceof Contact) {
            try {

                MessageArguments msgArgs = new MessageArguments (MessageArguments.ARG_NEW, "", "Hello there", ""); 
                Invoke.invokeApplication(Invoke.APP_TYPE_MESSAGES, msgArgs);
            } catch (Exception e) {
                //final String msg = e.getMessage(); 
                //net.rim.device.api.ui.component.Dialog.alert("Error starting app: "+msg);
                Dialog.alert("error sending sms");

        return context;
The issue i'm having is trying to get the code to go into the if loop. The only thing i can think of is that the instance is wrong, but all of my research is saying that i should be using 'Contact'. Anyone know if that is correct or not? or am i just too much of a noob and this can't be done at all? or does something like this already exist and i can just use that as a template?

thanks for any help.
Old 06-25-2009, 02:36 PM   #2 (permalink)
BlackBerry Extraordinaire
Join Date: Jan 2006
Model: LEZ10
OS: 10.0.10
Carrier: Rogers CA
Posts: 1,704
Post Thanks: 20
Thanked 77 Times in 68 Posts

Run the code in the simulator, put a breakpoint on the if statement and when it stops there use the inspector to find out what context really is an instance of.
My other Blackberry is a PlayBook.
Old 07-15-2009, 01:26 AM   #3 (permalink)
Thumbs Must Hurt
Join Date: Jun 2008
Model: 9000
Carrier: Airtel
Posts: 81
Post Thanks: 0
Thanked 0 Times in 0 Posts

i think try this
if (BlackBerryContact instanceof Contact)
it works in my code.

Copyright 2004-2016
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.