|
Hi Poonam,
You can send a text message with the following codes
MessageConnection conn =(MessageConnection) Connector.open("sms://5550001:1234");
TextMessage txtmessage = (TextMessage) conn.newMessage(
MessageConnection.TEXT_MESSAGE);
txtmessage.setPayloadText(msgString);
conn.send(txtmessage);
You can receive the message in two different ways:
1) Blocking the call
2) unblocking the call
First way:
conn = (MessageConnection) Connector.open("sms://5550001:1234");
msg = conn.receive(); // Blocking here
mSenderAddress = msg.getAddress(); // Get info from message
if (msg instanceof TextMessage) {
String msgReceived = ((TextMessage)msg).getPayloadText();
// Do something with the message here
} else if (msg instanceof BinaryMessage) {
byte [] msgReceived = ((BinaryMessage)msg).getPlayloadData();
// do something with the binary message here
}
}
Second Way:
For second way, register to the Interface like MessageListener
Regards,
sk_shadul
|