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.

New Developer
Posts: 2
Registered: ‎09-10-2009
My Device: Not Specified
Accepted Solution

Error trying to send a sms message from my application

 I am trying to send a SMS message from my application. So i do the following to send a message 
     public boolean sendSMS(String link) {
         TextMessage text = null;
         try {
             MessageConnection conn = (MessageConnection) Connector.open("sms://");
             text = (TextMessage) conn.newMessage(MessageConnection.TEXT_MESSAGE);
         } catch (Exception e) {
             Logger.logException("Exception creating sms message: "+ e.toString(), e);
             return false;
         if (link != null) {
             Invoke.invokeApplication(Invoke.APP_TYPE_MESSAGES, new MessageArguments(text));
         } else {
             Logger.logMessage("Unable to send SMS at this time. Please try again later.");
             return false;
         return true;
 In the above code I create a MessageConnection by passing "sms://" since a MessageConnection cannot be created with a space. 
 After I execute the above code the control is navigated to RIM's SMS application. Here the user can add new one time recipient or add a number from his address book and send the SMS. 
 The problem is when the user sends the SMS, behinds the scene two SMS's messages are being tried to sent. One for the recipient added by the BB user and the other recipient with the TO number as "sms://" which was added by me to display RIM's SMS application. Eventually the recipient with "sms://" fails and sits in the users send SMS folder as failed. To the end user it seems like the message was not sent to the recipient which he just added from the address book. In reality the message does get sent successfully to the recipient which he just added from the address book and the failed message is the TO number with "sms://" which was added initially to display RIM's SMS application.  
 Is there a way I can open a SMS message with no recipient? The user can always add recipient in the RIM's SMS application.
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Error trying to send a sms message from my application

I don't understand what you are using MessageConnection for. It's not needed here, I don't think.


If you are sending the SMS using RIM's Messages app, just create the Message object and pass it as an argument in the invoke statement.



Posts: 112
Registered: ‎07-19-2009
My Device: Not Specified

Re: Error trying to send a sms message from my application



You're trying to techniques at the same time when only one is required. You'll have to use any of the following.


1. Create an application which uses the message connection to send sms as described below.


smsAddress = "9876543210";

smsText = "Sending SMS from my application";

//connect and send message

MessageConnection messageConnection = (MessageConnection) Connector.open("sms://" + smsAddress);

TextMessage sms = (TextMessage)messageConnection.newMessage(MessageConnection.TEXT_MESSAGE);





2. Invoke the native BlackBerry SMS application available in your device.


Invoke.invokeApplication(Invoke.APP_TYPE_MESSAGES, new MessageArguments(text));

Posts: 16
Registered: ‎01-12-2009
My Device: 9000

Re: Error trying to send a sms message from my application

Another option is to just create your own implementation of TextMessage and use that instead of opening an essentially-useless connection just to get an instance of TextMessage.  The TextMessage interface is very small and straight-forward, very easy to implement yourself.



public class MyTextMessage implements TextMessage {

private final Date _timestamp;
private String _payloadText;
private String _address;

public MyTextMessage() {
this._timestamp = new Date();

public String getAddress() {
return this._address;

public String getPayloadText() {
return this._payloadText;

public Date getTimestamp() {
return this._timestamp;

public void setAddress(String address) {
this._address = address;

public void setPayloadText(String payloadText) {
this._payloadText = payloadText;



 Then, to launch the message app for the user do something like this:



TextMessage textMessage = new MyTextMessage(); textMessage.setPayloadText("Hey, this is the message body"); textMessage.setAddress("sms://+15556667777"); MessageArguments args = new MessageArguments(textMessage); Invoke.invokeApplication(Invoke.APP_TYPE_MESSAGES, args);





New Developer
Posts: 2
Registered: ‎09-10-2009
My Device: Not Specified

Re: Error trying to send a sms message from my application

Thanks a lot dconeybeare your solution worked for me. Especially since i had no number to pass into this (MessageConnection) Connector.open(""); 



Posts: 1,638
Registered: ‎07-14-2008
My Device: Z10
My Carrier: Fido

Re: Error trying to send a sms message from my application

this does not work on OS5 Smiley Sad