Reputation: 874
I'm trying to send a message from a vector of numbers, everything works fine in the simulators but when i try it on a real device (9630) nothing happens (no exceptions thrown either). I've tried with and without port numbers and am running out of ideas, any help would be greatly appreciated, thanks. Here is my code:
for(int i=0; i<_cntctsNmbrs.size(); i++) {
_conn = (MessageConnection)Connector.open("sms://"+_cntctsNmbrs.elementAt(i)+":0");
final TextMessage msgOut = (TextMessage)_conn.newMessage(MessageConnection.TEXT_MESSAGE);
msgOut.setPayloadText(frmtdMsg);
_conn.send(msgOut);
_conn.close();
}
Upvotes: 1
Views: 187
Reputation: 1669
MessageConnection message_connection = null;
try {
message_connection = (MessageConnection) Connector.open("sms://");
TextMessage text_message = (TextMessage) message_connection
.newMessage(MessageConnection.TEXT_MESSAGE);
text_message.setAddress("sms://" + SMS_PHONE_NUMBER);
text_message.setPayloadText(smsContent);
message_connection.send(text_message);
} catch (IOException e) {
}
The above code working fine in GSM devices.
Upvotes: 0
Reputation: 874
All it took was to send using a DatagramConnection, working fine now, thanks.
DatagramConnection dgConn;
dgConn = (DatagramConnection)Connector.open("sms://" + _cntctsNmbrs.elementAt(i));
byte[] data = "MessageBody".getBytes();
Datagram dg = dgConn.newDatagram(dgConn.getMaximumLength());
dg.setData(data, 0, data.length);
dgConn.send(dg);
Upvotes: 1