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 Contributor
baggiochen10
Posts: 3
Registered: ‎10-11-2012
My Device: 9900
My Carrier: xiaomi

send sms with encoding issue

When I send sms as following code, there is a problem that the text show like ???? on the system Text Messages UI. the text I send is Chinese. MessageConnection mc = (MessageConnection)Connector.open( "sms://" ); TextMessage m = (TextMessage)mc.newMessage( MessageConnection.TEXT_MESSAGE ); m.setAddress( "sms://" + friend.getMoblie() ); String text = "中国"; m.setPayloadText(text); Invoke.invokeApplication( Invoke.APP_TYPE_MESSAGES, new MessageArguments( m ) ); I hava try this on 9810, 9780, both are ok, but on the 9900 and 9930, it is terrible. Need Help. Thanks in advance!
Please use plain text.
Developer
hemant_sain
Posts: 178
Registered: ‎12-09-2011
My Device: 9360, BB10
My Carrier: Aircel

Re: send sms with encoding issue

I think your device is not compatible for Chinese language thats why it is showing ????.

 

So first check your device is Chinese language supported or not?

Please use plain text.
New Contributor
baggiochen10
Posts: 3
Registered: ‎10-11-2012
My Device: 9900
My Carrier: xiaomi

Re: send sms with encoding issue

Thanks for your reply. I found the root cause of that is the sms app default encoding of the device is 7 bit, not UCS2, so cant show Chinese. But there is another problem, as we cant use MessageConnection to send sms on CDMA device. we need use DatagramConnection and Datagram. How to send Datagram by system sms app? Invoke.invokeApplication( Invoke.APP_TYPE_MESSAGES, new MessageArguments( ) ); I dont know how to write the code? can U help ?
Please use plain text.
Developer
hemant_sain
Posts: 178
Registered: ‎12-09-2011
My Device: 9360, BB10
My Carrier: Aircel

Re: send sms with encoding issue

use this code may be this can help you:

 

public void sendSMS_CDMA(String strMessage, String strNumber)
	{
		try {
			  byte[] data = (strMessage).getBytes("UTF-8");
			  connection = (DatagramConnection) Connector.open("sms://" + strNumber );
			  Datagram dg = connection.newDatagram(connection.getMaximumLength());
			  dg.setData(data, 0, data.length);
			  connection.send(dg);
			  System.out.println("Message sent successfully " + strMessage);
			  
		} catch (IOException e) {
			System.err.println("Unable to send SMS "+e.toString());
		} finally {
			  try {
			    connection.close();
			    connection=null;
			  }catch(Exception e){}
		}
	}

 

Please use plain text.