Send Message in J2ME

May 7, 2008 at 5:14 am (Mobile, Uncategorized)

Sample code for sending a message using J2ME: You can send message with or without port.

MessageConnection smsconn = null;

try {

/** Open the message connection. */

smsconn = (MessageConnection)Connector.open(address);

TextMessage txtmessage =

(TextMessage)smsconn.newMessage(MessageConnection.TEXT_MESSAGE);

txtmessage.setAddress(address);

txtmessage.setPayloadText(messageBox.getString());

smsconn.send(txtmessage);

} catch (Throwable t) {

t.printStackTrace();

}

if (smsconn != null) {

try {

smsconn.close();

} catch (IOException ioe) {

System.out.println(“Closing connection caught: “);

ioe.printStackTrace();

}

}

Advertisements

1 Comment

  1. Alexwebmaster said,

    Hello webmaster
    I would like to share with you a link to your site
    write me here preonrelt@mail.ru

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: