Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Revision as of 12:47, 5 June 2009 by tanjaluodes (Talk | contribs)

How to send Binary SMS in Java ME

From Wiki
Jump to: navigation, search


The following Java ME tip explains 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.

void sendSMS(byte data[]) {
 
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) {
 
}

}

81 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×