【问题标题】:Unable to send SMS message in Hindi无法用印地语发送短信
【发布时间】:2013-05-24 08:21:28
【问题描述】:

我在 Android 中遇到了 SMSManager 的一个奇怪问题。我用两种语言发送短信,印地语和英语。消息发送适用于英文消息,但如果是印地语文本,则消息不会被传递。我什至没有收到任何关于印地语消息失败或成功的广播。

这是我发送消息的代码。

SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(destinationAddress, null, message, null, null);

PS。

我准备了一个发送消息的示例应用程序。当用印地语在 EditText 中输入消息时它工作正常,但在印地语字符串被硬编码时无法发送消息。

String hindiMessage = editText.getText.toString()// works fine  

String hindiMessage = "हिन्दी संदेश"//fails

我正在寻找任何可能的解决方案或解决方法。

【问题讨论】:

  • 好吧,我只是在我的设备上尝试了同样的方法。没问题,消息也以印地语传递。在三星 Galaxy s3 上测试
  • 是硬编码印地语字符串。在我的设备上运行良好
  • @raghunandan 得到了问题的答案。 :)。

标签: android sms


【解决方案1】:

这已通过将消息作为多部分消息发送来解决。 SMS 以英语工作,因为我发送的消息长度小于一条消息的最大长度。但是在将其转换为印地语后,它的长度会增加并超过一条消息的最大限制。

因此,将消息作为多部分消息发送对我有用。这是相同的代码:

SmsManager smsManager = SmsManager.getDefault();
ArrayList<String> parts = smsManager.divideMessage(message);
smsManager.sendMultipartTextMessage(destinationAddress, null, parts, null, null); 

谢谢
N_JOY。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-11-02
    • 2018-10-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多