开发者

Problem using J2ME WMA to send/receive SMS

开发者 https://www.devze.com 2023-02-05 01:04 出处:网络
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 (listene

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;
}
0

精彩评论

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

关注公众号