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
Posts: 72
Registered: ‎08-28-2008
My Device: Not Specified

SMS send issue??

Hi All,

i am trying to send SMS programatically, i am not able to send sms with real device with the below mentioned code
[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
conn.send(tmsg);

[/code]

 

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.

Questions
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....

Regards,
Vijay Saini.
--------------------------------------------------------------------------------
If your problem was get solved then please mark the thread as "Accepted solution" and kudos - your wish
Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: SMS send issue??

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.

 

 

 

New Developer
Posts: 72
Registered: ‎08-28-2008
My Device: Not Specified

Re: SMS send issue??

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

Regards,
Vijay Saini.
--------------------------------------------------------------------------------
If your problem was get solved then please mark the thread as "Accepted solution" and kudos - your wish
Highlighted
Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: SMS send issue??

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).