为什么无法从 Blackberry 组地址发送 MessageConnection 消息?
我试图一次发送大量短信,当我从联系人本身提取号码时,它工作正常,但是当我从组中获取它们时,我收到一个 IllegalArgumentException ,上面写着“无效的目标地址:尾随字符: " 后跟收件人号码。
我从联系人那里得到了这样的号码:
private void addContactGroup(BlackBerryContactGroup group) {
BlackBerryContact contact;
for(int i=0;i<group.numContacts();i++) {
_cntctsNmbrs.addElement(group.getAddress(i).trim());
}
}
然后我发送消息:
try {
_conn = (MessageConnection)Connector.open("sms://");
final TextMessage msgOut = (TextMessage)
_conn.newMessage(MessageConnection.TEXT_MESSAGE,
"sms://"+_cntctsNmbrs.elementAt(i)+":0");
msgOut.setPayloadText(frmtdMsg);
_conn.send(msgOut);
} catch (final Exception e) {}
我到处搜索,但在任何地方都找不到这个错误。
I'm trying to send a lot of sms texts all at once, it works fine when i pull the numbers from the contacts themselves, but when i get them from the group i get an IllegalArgumentException that says "invalid destination address: trailing characters:" followed by the recipient's number.
I get the numbers from the contacts like this:
private void addContactGroup(BlackBerryContactGroup group) {
BlackBerryContact contact;
for(int i=0;i<group.numContacts();i++) {
_cntctsNmbrs.addElement(group.getAddress(i).trim());
}
}
And then i send the message:
try {
_conn = (MessageConnection)Connector.open("sms://");
final TextMessage msgOut = (TextMessage)
_conn.newMessage(MessageConnection.TEXT_MESSAGE,
"sms://"+_cntctsNmbrs.elementAt(i)+":0");
msgOut.setPayloadText(frmtdMsg);
_conn.send(msgOut);
} catch (final Exception e) {}
I searched all over but couldn't find this error anywhere.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实证明,一些边缘操作将不可见的控制字符添加到组地址的字符串中,我只是为每个地址调用了
stringbuf.deleteCharAt(0)
,结果就解决了it turns out that some of the rim oses add invisible control characters to the strings of group's addresses, i just called
stringbuf.deleteCharAt(0)
for each address and it worked out