Results 1 to 4 of 4

Thread: sms midlet

  1. #1
    Poonam is offline Member
    Join Date
    Nov 2007
    Posts
    15
    Rep Power
    0

    Default sms midlet

    Hello All,
    How can we send and receive sms in midlet,and how can we test receiving of message.

  2. #2
    sk_shadul is offline Member
    Join Date
    Mar 2008
    Posts
    5
    Rep Power
    0

    Default

    Hi Poonam,

    You can send a text message with the following codes
    MessageConnection conn =(MessageConnection) Connector.open("sms://5550001:1234");
    TextMessage txtmessage = (TextMessage) conn.newMessage(
    MessageConnection.TEXT_MESSAGE);
    txtmessage.setPayloadText(msgString);
    conn.send(txtmessage);

    You can receive the message in two different ways:
    1) Blocking the call
    2) unblocking the call

    First way:

    conn = (MessageConnection) Connector.open("sms://5550001:1234");
    msg = conn.receive(); // Blocking here
    mSenderAddress = msg.getAddress(); // Get info from message
    if (msg instanceof TextMessage) {
    String msgReceived = ((TextMessage)msg).getPayloadText();
    // Do something with the message here
    } else if (msg instanceof BinaryMessage) {
    byte [] msgReceived = ((BinaryMessage)msg).getPlayloadData();
    // do something with the binary message here
    }
    }

    Second Way:

    For second way, register to the Interface like MessageListener


    Regards,
    sk_shadul

  3. #3
    zhangwanhua is offline Member
    Join Date
    Nov 2009
    Posts
    3
    Rep Power
    0

    Default

    can we receiving SMS from java midlet without a specific port??

  4. #4
    dswastik is offline Senior Member
    Join Date
    Dec 2008
    Location
    Kolkata
    Posts
    286
    Rep Power
    13

    Default

    You can't, messages sent to default port will always go to message inbox.

Similar Threads

  1. Using Alert in MIDlet
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-22-2007, 10:22 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •