BlackBerry - Exception with null message when sending sms using Connector

Posted by vikram deshpande on Stack Overflow See other posts from Stack Overflow or by vikram deshpande
Published on 2010-03-22T08:59:19Z Indexed on 2010/03/22 11:21 UTC
Read the original article Hit count: 300

Filed under:
|
|
|
|

I used code given but I am getting "IOCancelledException" and "IOException". And IOCancelledException.getMessage() / IOException.getMessage() giving null string, it does not give error message. Please help me understaing reason.

class SMSThread extends Thread {
    Thread myThread;
    MessageConnection msgConn;
    String message;
    String mobilenumber;

    public SMSThread(String textMsg, String mobileNumber) {
        message = textMsg;
        mobilenumber = mobileNumber;
    }

    public void run() {
        try {
            msgConn = (MessageConnection) Connector.open("sms://+"
                    + mobilenumber);
            TextMessage text = (TextMessage) msgConn
                    .newMessage(MessageConnection.TEXT_MESSAGE);
            text.setPayloadText(message);
            msgConn.send(text);
            msgConn.close();
        } catch (IOCancelledException ioce) {
            System.out
                    .println("IOCancelledException: " + ioce.getMessage());
        } catch (IOException ioe) {
            System.out.println("IOException: " + ioe.getMessage());
        } catch (Exception e) {
            System.out.println("Exception: " + e);
        }
    }
}

© Stack Overflow or respective owner

Related posts about blackberry

Related posts about sms