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
PIN: N/A
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:
Code:
public Object run(Object context) {
        if (context instanceof Contact) {
            try {

                MessageArguments msgArgs = new MessageArguments (MessageArguments.ARG_NEW, "a@a.com", "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.
Offline  
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
Default

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.
Offline  
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
Default

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


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.