开发者

solution an error in receive sms

When send sms from a device to another sometime it received in both devices.

I don't find any error in source code.

Please help me.

NOTE:

this is send source code:

try {
String addr = "sms://" + txt_number.getString开发者_如何学JAVA()+":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();
}
}


Remove the port number when sending the SMS.


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

should be

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

port number should be without any quotes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜