Namespaces
Variants
Actions

How to send Binary SMS in Java ME

Jump to: navigation, search

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.

SignpostIcon Messages 52.png
Article Metadata

Article
Created: wang_shui (21 Mar 2007)
Last edited: hamishwillee (10 Sep 2012)
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;
}
This page was last modified on 10 September 2012, at 10:27.
219 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved