【问题标题】:solution an error in receive sms接收短信出错的解决方法
【发布时间】:2011-09-14 08:05:11
【问题描述】:

当从一个设备向另一个设备发送短信时,它会在两个设备中收到。
我在源代码中没有发现任何错误。
请帮帮我。
注意:
这是发送源代码:

try {
String addr = "sms://" + txt_number.getString()+":1234";
MessageConnection conn = (MessageConnection) Connector.open(addr);
TextMessage msg = (TextMessage) conn.newMessage(MessageConnection.TEXT_MESSAGE);
msg.setPayloadText(txtSMS.getString());
conn.send(msg);
conn.close();
} catch (IOException ex) {  ex.printStackTrace();  }
<blink>and this is receive opretion .this opration support by a thread <blink>
public void run() {
String addr="sms://:1234";
Message msg=null;
try {
conn = (MessageConnection) Connector.open(addr);
while(true)
{               
msg=conn.receive();
String mSenderAddress = msg.getAddress();
if (msg instanceof TextMessage) {
String msgTReceived = ((TextMessage)msg).getPayloadText();
Analize_TEXT_message(mSenderAddress,msgTReceived);
}
}
} catch (IOException ex) {
ex.printStackTrace();
}
}

【问题讨论】:

    标签: java-me sms


    【解决方案1】:

    发送短信时去掉端口号

    【讨论】:

      【解决方案2】:

      String addr = "sms://" + txt_number.getString()+":1234";

      应该是

      String addr = "sms://" + txt_number.getString()+1234;
      

      端口号不能加引号。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2012-03-07
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-04-06
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多