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
haiau
Posts: 4
Registered: ‎09-29-2009
My Device: Not Specified

Weird sms content when sending datagram sms

Hi all,

 

I'm newbie in blackberry development, please somebody help me with this problem. I used MessageConnection for sending sms and it doesn't work with CDMA, so I switch to DatagramConnection. However, when I send the message as the code below, the message content is messed up. In the receiver phone (no programming at this end), instead of the content "Test Message", I got something like È€◊‡€◊‡ 

 

Please help me to format the message content to readable format! Thanks !

 

 

public void sendsms(){
DatagramConnection dgConn;
try{
dgConn = (DatagramConnection)Connector.open("sms://xxxxxxxxxxx");
byte[] data = "Test Message".getBytes();
Datagram dg = dgConn.newDatagram(dgConn.getMaximumLength());
dg.setData(data, 0, data.length);
dgConn.send(dg);
} catch (IOException e) {
// Likely the stream was closed.
System.err.println(e.toString());
}
}

 

New Developer
haiau
Posts: 4
Registered: ‎09-29-2009
My Device: Not Specified

Re: Weird sms content when sending datagram sms

I searched this problem. Haven't found solution yet. Anyone encountered this problem? I sent message from Blackberry Bold (GSM) to Blackberry 7250 (CDMA)
Developer
Developer
CMY
Posts: 1,123
Registered: ‎02-10-2009
My Device: 8130 / 8350 / 9530 / 9550 / 9850 / PlayBook

Re: Weird sms content when sending datagram sms

I think this is due to the string encoding difference between the receiving/sending devices. I think I read somewhere that the Datagram object does not work well with certain encodings or when the encodings differ.
New Developer
haiau
Posts: 4
Registered: ‎09-29-2009
My Device: Not Specified

Re: Weird sms content when sending datagram sms

I think so, but how can I set it to right encoding. I sent to GSM phone as well, same problem.
New Developer
haiau
Posts: 4
Registered: ‎09-29-2009
My Device: Not Specified

Re: Weird sms content when sending datagram sms

I tried different encoding. Some encoding can be sent to certain phone or network, some don't. Why sending sms manually, the message always being sent? Is there a way to make it work for any network?

 

Thanks

Developer
sreid55
Posts: 41
Registered: ‎09-28-2009
My Device: Not Specified

Re: Weird sms content when sending datagram sms

Haiau - Did you ever come up with a solution on this one?  I think I'm encountering the same problem...

Scott