Java ME Developer Guide

Chapter 9 - JSR-120 - Wireless Messaging API

Creation of client connection without port number:

MessageConnection messageConnection = (MessageConnection)Connector.open("sms://+18473297274");

Closing of connection:

MessageConnection messageConnection.close();

Creation of SMS message:

Message textMessage = messageConnection.newMessage(MessageConnection. TEXT_MESSAGE);

Setting of payload text for text message:

((TextMessage)message).setPayloadText("Text Message");

Getting of payload text of received text message:

receivedText = ((TextMessage)receivedMessage).getPayloadText();

Getting of payload data of received binary message:

BinaryMessage binMsg;

byte[] payloadData = binMsg.getPayloadData();

Setting of address with port number:

message.setAddress("sms://+18473297274:9532");

Setting of address without port number:

message.setAddress("sms://+18473297274");

Sending of message:

messageConnection.send(message);

Receiving of message:

Message receivedMessage = messageConnection.receive();

Getting of address:

DRAFT - Subject to Change [70/201]

Page 70
Image 70
Motorola maxx V6 manual Draft Subject to Change 70/201