How to send Binary SMS in Java ME
This Java ME code snippet shows a method of sending binary messages such as PNG images, sound files etc. In the program BinaryMessage interface represents a binary message. The setPayloadData() method sets the value of the payload in the data container without checking whether the value is valid or not.
Article Metadata
public boolean sendSMS(byte data[]) {
boolean result = true;
try {
String destAddress = "sms://9772625262:5000";
MessageConnection smsConnection = (MessageConnection)Connector.open(destAddress);
//Create binary message
BinaryMessage binaryMSG = (BinaryMessage)smsConnection.newMessage(MessageConnection.BINARY_MESSAGE);
//Setting destination add
binaryMSG.setAddress(destAddress);
//Add payload data
binaryMSG.setPayloadData(data);
//Now send the message
smsConnection.send(binaryMSG);
smsConnection.close();
} catch (Exception e) {
result = false;
}
return result;
}


19 Sep
2009
Level: Basic
This article shows how you can send picture,sound,etc.. multimedia messages to other phones through message Sending.
First it converts multimedia things into binary codes and then sends it to destination phones through message sending.