Join Now
Quality Rating:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)
Expertise Level:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)

This page was last modified 23:25, 26 March 2008.

How to Send Text SMS in Java ME

From Forum Nokia Wiki


The following Java ME tip explains a method of sending text messages . In the program TextMessage interface represents a text message. The setPayloadText() method sets the characters in the message.

public boolean sendSms(String number, String message){
    boolean result = true;
    try {
      //sets address to send message
      String addr = "sms://"+number;
      // opens connection
      MessageConnection conn = (MessageConnection) Connector.open(addr);
      // prepares text message
      TextMessage msg =
      (TextMessage)conn.newMessage(MessageConnection.TEXT_MESSAGE);
      //set text
      msg.setPayloadText(message);
      // send message
      conn.send(msg);
      conn.close();
      } catch (Exception e) {
        result = false;
      }
      return result;
  }

Remember that a message has a maximum size ( normally around 160 chars). If your message is too long to fit in one message it can be splitted to a maximum of three SMS, this is handled automatic by the WMA implementation.

Related Discussions
Thread Thread Starter Forum Replies Last Post
Sending SMS from Java application on PC General Messaging 3 2002-08-22 11:24
how to send sms faster? kepalle General Messaging 12 2007-04-06 07:38
SMS receive baruchs Mobile Java General 4 2003-06-21 16:58
send text file to message khemarak_168 General Symbian C++ 3 2007-01-22 05:41
How to Know the SimCard Number using J2ME APIs. jayvijayraj Developer Resources Feedback (Documentation, Examples, Training) 3 2007-02-13 09:39
 
Powered by MediaWiki