0

I send SMS with this code

SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage("Numerber", null, "Text to send", null, null);

It works pretty well in English, but if I use Spanish it fails. After many tries I found out that the message sent got cropped if the "Text to send" contains accents like "á, é, í, ó, ú"

Of course those accents are needed in Spanish in a proper way of writing, so any idea about this?

Ton
  • 9,235
  • 15
  • 59
  • 103
  • Obviously the problem is connected to encoding. Are you sure you are using UTF-8, otherwise can you convert to it? – Itay Grudev Feb 18 '13 at 19:03
  • 2
    Apparently using `sendMultipartTextMessage` instead of `sendTextMessage` results in correct encoding support (See the dupe link) – Basic Feb 18 '13 at 19:04
  • Keep in mind- sending those accents requires you to use unicode, so you go down to a max of 70 chars per message. Some users don't like that, if their message is being sent – Gabe Sechan Feb 18 '13 at 19:07
  • Try this: Html.fromHtml(new String(myString.getBytes("UTF-8"))).toString(); and SMS message it looks perfect. – Cristi Maris Sep 22 '15 at 08:33

1 Answers1

1

Thanks to all of you. Yes, it is what you said. Here is the solution:

ArrayList<String> arrSMS = smsManager.divideMessage("Text to send");
smsManager.sendMultipartTextMessage("Number", null, arrSMS, null, null);
Ton
  • 9,235
  • 15
  • 59
  • 103