I'm using WMADemo of the JavaME SDK 3.0 and it's working fine in simulator.
When I install the application in a mobile device it doesn't work. I tried both port 0 (default SMS) and 50000 (listener) w开发者_开发问答ith no success. No exception was thrown.
This is an example that works for me
try {
String dest = "sms://" + yourRecipientNumberString;
MessageConnection mConn = (MessageConnection) Connector.open(dest);
TextMessage sms = (TextMessage) mConn.newMessage(MessageConnection.TEXT_MESSAGE);
sms.setPayloadText(msgText);
mConn.send(sms);
mConn.close();
sent = true;
} catch (IOException ioe) {
ioe.printStackTrace();
sent = false;
} catch (IllegalArgumentException iae) {
iae.printStackTrace();
sent = false;
} catch (SecurityException se) {
se.printStackTrace();
sent = false;
}
精彩评论