【发布时间】:2014-07-07 14:49:04
【问题描述】:
我正在尝试使用我的应用程序发送 SMS 消息。
但是,通过我的应用程序发送消息时,我的消息在 67 个字符后被截断。我知道 SMS 的最大长度为 160 个字符,并且可以使用原生 Android 消息应用程序发送此长度的消息。
这是我的代码:
String textToSend = "this is a string that is about 100 characters or so. It is being split up by android after 67 characters.";
SmsManager sms = SmsManager.getDefault();
ArrayList<String> msgStringArray = sms.divideMessage(textToSend);
for(String s : msgStringArray){
//this will say 67 and then the remainder
Log.d(TAG, "STRING LENGTH: " + s.length() + " " + s);
}
sms.sendMultipartTextMessage(selectedNumber, null, msgStringArray, null, null);
我认为这可能是编码或类似的东西。我认为默认情况下使用 16 位编码而不是 GSM,但我无法找到任何解决此问题的示例。一个代码示例会很棒!
我在 S3 上使用 android 4.4 来测试这个。
谢谢!
【问题讨论】:
-
如果您要发送多部分 mime,我认为 mime 标头会占用一些空间