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
New Developer
mas7967
Posts: 3
Registered: ‎06-18-2009
My Device: Not Specified

Sending an SMS

Hello,

 

I've just started doing work with making apps and have been trying out lots of stuff.  Right now I'm trying to write an application that can send an SMS message to a given number, is this possible?

 

I've been reading all through the docs and I found an SMS sample code file but it doesn't seem to help.  They start listeners and send messages and stuff but how do I specify where the message is to be sent?

 

I am using the Blackberry JDE version 4.7 right now.

 

Any help on this topic would be greatly appreciated.

 

Thanks in advance,

 

Mark

 

 

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

Re: Sending an SMS

Along with JDE there are samples coming when you install JDE on the computer.

 

Check JDE folder for samples.

 

There is SMSDemo application.

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

Re: Sending an SMS

If you're referring to the smsdemo shipped with the BlackBerry plugin, the example sends the message to the number specified by the user in the EditField (private EditField _sendText:smileywink:

 

If you want to send the message to a single (fixed) number, you can either hard code it or specify it in a resource file.

 

Here's a code sample to help you.

 

String smsAddress = "9876543210"; 

String smsText = "Hi, this is my first sms"; 

 

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

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

sms.setPayloadText(smsText);

 

messageConnection.send(sms);