11-25-2008 04:51 PM
i am trying to send SMS programatically, i am not able to send sms with real device with the below mentioned code
MessageConnection conn = (MessageConnection) Connector.open("sms://");
//generate a new text message
TextMessage tmsg = (TextMessage) conn.newMessage(MessageConnection.TEXT_MESSAGE);
//set the message text and the address
tmsg.setAddress("sms://" + 9871180730);
tmsg.setPayloadText("Test SMS From blackberry.");
//finally send our message
when i run this code on simulator, it seems like this code is working. but sms not appears in message outbox folder. is something wrong with code?
when i run this code on real device then i am getting java.lang.StringIndexOutOfBoundsException: String index out of range: 2.
1: is it possible to send SMS without specifying the port?
2: if i send SMS without port then this SMS appears in recipient Outbox folder of all device?
can anyone help me on this.
Thanks in Advance....
11-25-2008 06:35 PM
If you are getting the StringIndexOutOfBounds on 4.3.0.xx, then I am guessing you have a Application Permissions issue.
On some versions of 4.3.0, the system throws this exception when trying to instantiate a Permissions "Ask" dialog.
Set all of your Application permissions to ALLOW and try it again.
11-26-2008 12:35 PM
RexDoug Thanks for your help.
By changing "Carrier internet" application permission from "prompt" to "allow". then sms successfully send.
i have tried my sms app on 4.5, it works in case of carrier internet permission is set to prompt.
the problem, i have seen is that, sent sms message is not showing in message outbox/sms list screen. but when i send sms with native app, it appers in list.
So my question is
1: what i can do to sent sms appers in SMS list screen? shall i have to sent it with some specified port.
2: i am getting alert message when i send sms by my app as mentioned below
"the application smsdemo has requested a sms connetion to listen to messages"
Don't ask this again for
all sms connection
sms connections to listen to messages
So my question is why i am getting this alert because i am not listening message. i am just sending sms message.
Thanks in advance
11-26-2008 03:48 PM
You are creating a Connection, therefore you are implicitly asking for permission to go in both directions.
The only way I know of to make the SMS appear in the message list is to allow the messages application to send it for you, if this is acceptable for your application.
You can create the textmessage and invoke the Messages application using the Invoke API (see the API docs).
This method will actually solve two of your problems (security and getting the message in the list).