gpt4 book ai didi

android - 在模拟器之间发送短信

转载 作者:行者123 更新时间:2023-11-29 01:22:46 25 4
gpt4 key购买 nike

我正在尝试从模拟器向模拟器发送短信。它可以工作,但只能使用非常有限的字符集(ASCII 的子集)。如果我在消息中包含以下任何字符,则这些字符第一次出现后的任何内容都将变成乱码:

|, ^, {, }, €, [, ~, ] and \

(但我还需要非 ASCII 字符,例如希伯来字母表)

例如,如果我发送 Hello ^ World,它将变成 Hello ^

或者 [Hello:World] 变成类似 [ e ]

这是我使用的代码:

void sendSms(final String toNumber, final String message) {
final SmsManager sm = SmsManager.getDefault();
if (message.getBytes().length <= 160) {
sm.sendTextMessage(toNumber, null, message, null, null);
} else {
ArrayList<String> msgStringArray = sm.divideMessage(message);
sm.sendMultipartTextMessage(toNumber, null, msgStringArray, null, null);
}
Log.v(TAG, "sendSms: " + toNumber + ", " + message + ", " + message.length() + " chars / " + message.getBytes().length + " bytes");
}

我用来接收消息的代码在这里:Receive an read SMS with correct encoding and convert to UTF8

最佳答案

这似乎是模拟器中的错误:https://code.google.com/p/android/issues/detail?id=202723

Though I don't have an immediate solution, it is worth mentioning that Emulator 2.0 includes a UI for sending SMS messages to the virtual device, and the aforementioned characters all work fine when sent from that UI. If you need to do some testing with a device receiving (but not sending) an SMS message containing those characters, that should do the trick until we track down this bug. You can get access to Emulator 2.0 from the preview release channel as part of tools 25.0.

关于android - 在模拟器之间发送短信,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35847301/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com