The third parameter of sendTextMessage()
is an ordinary String
. There is no need to convert a String
to a UTF-8 encoded byte[]
array and then back to a String
again (especially since you are not doing that last conversion correctly). Get rid of getBytes()
altogether and just use "@"
as-is:
String message = "@";
manager.sendTextMessage(phonenumber, null, message, piSend, piDelivered);
Or simply:
manager.sendTextMessage(phonenumber, null, "@", piSend, piDelivered);
It does make sense to use getBytes()
when using sendDataMessage()
instead.
Update: doing some research, I see that SMS can use one of three different character encodings. In GSM-03.38 encoding, a @
character is usually encoded as octet 0x00
, not as octet 0x40
like it is in standard ASCII-compatible charsets. So that might be causing some issues for your carriers if your device is using GSM encoding internally. You may have to use sendDataMessage()
instead so you can encode the String
data to UTF-16, if your device does not automatically handle that for you (I would expect Android to handle that internally, but who knows if it really does). You might have to do that anyway if you want to send international or other non-alphanumeric characters:
manager.sendDataMessage(phonenumber, null, 8091, message.getBytes("UTF-16"), piSend,
piDelivered);