10
JSR
120 – Wireless Messaging API
45
byte[] newBin = new byte[size];
for (int i = 0; i < size; i++) {
nextByte
=
(rand.nextInt());
newBin[i]
=
(byte)nextByte;
if ((size > 4) && (i == size / 2)) {
newBin[i-1]
=
0x1b;
newBin[i]
=
0x7f;
}
}
return
newBin;
}
byte[] newBin = createBinary(msgLength);
binMsg.setPayloadData(newBin);
int num = connClient.numberOfSegments(binMsg);
Creation of server connection:
MessageConnection messageConnection =
(MessageConnection)Connector.open("sms://:9532");
Creation of client connection with port number:
MessageConnection messageConnection =
(MessageConnection)Connector.open("sms://+18473297274:9532");
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");
Содержание C381P J2ME
Страница 1: ...Technical Manual Version 01 00 Motorola C381p Handset J2ME Developer Guide ...
Страница 34: ...8 Network APIs 34 catch Exception ex hc i null Code Sample 3 HTTPS Connection ...
Страница 48: ...10 JSR 120 Wireless Messaging API 48 e toString Code Sample 5 JSR 120 Wireless Messaging API ...