简体   繁体   中英

Can't send sms on real device

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();

}

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);
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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM