Encoding SMS messages in Android

2019-03-11 20:12发布

My problem is that I want to send an SMS message of a certain Class and with a certain encoding. (Class 0 and 7-bit encoding).

When checking the Android.Telephony.SmsManager and SmsMessage there is not so much you can do. The SmsManager offers the two functions SendTextMessage and SendDataMessage. The first one works fine if you simply wants to send a normal SMS to somebody. So I guess that the SendDataMessage is the function that I somehow needs to use. However I can not figure out how to use it. And there seems to be no examples on the web (that I can find) of anyone using this function.

Does anyone know anything that would help me? :-) Either how to send a Class0 7-bit encoded sms, or how to use the SendDataMessage function properly.

1条回答
冷血范
2楼-- · 2019-03-11 20:27

The sendDataMessage function adds it's own user data header, UDH, information consisting of the application port number and a TP-Data-Coding-Scheme of no class, 8 bit data 0x04 (found in the SmsMessage code base)

the SendTextMessage function will send the message with GSM7packed encoding and a TP-Data-Encoding-Scheme of 0x00 - uncompressed, default (7bit) encoding, no class. Per the GSM 03.38 spec

For class 0, 7 bit data, you'd be looking for a 0x10 value in the TP-Data-Encoding-Scheme byte location. To do so, one would need to control all of the PDU being sent. Currently this is not supported by the public android API. However, it can be done (though highly discouraged) via reflection on the internal APIs.

See SMS raw pdu in Android

查看更多
登录 后发表回答