Android: How to send unicode sms programmatically and receive it from the other side correctly?

I use simple code to send sms:

SmsManager.getDefault(). sendTextMessage(phone, null, "English characters", sentPI, deliveredPI); 

And everything works great.

But when I send an sms message in romanian using this code:

 SmsManager.getDefault(). sendTextMessage(phone, null, " ", sentPI, deliveredPI); 

I get something like this on another emulator: *&^#R*)@#_(&)@U(RH#*(&()^

How can i fix this? Please, help.

+4
source share
3 answers

This seems like an emulator problem. I am using the SmsManager.sendMultipartTextMessage() method to send Russian text and no real user report of any problems. Try a real device, please.

+1
source

I would suggest that you need to create the string correctly.

For instance:

 new String(" ", "UTF-16BE"); 

Keep an eye on the source code file. It is usually safer to add Unicode character codes such as \ u0000. Otherwise, you should always be sure to save the source code in UTF16 format.

+1
source

Yes, this seems like an emulator error. This question has been moved to another: https://stackoverflow.com/questions/8901477/android-receiving-another-bytes-after-sending-sms

0
source

Source: https://habr.com/ru/post/1391150/


All Articles