package util;
import javax.microedition.io.Connector;
import javax.wireless.messaging.MessageConnection;
import javax.wireless.messaging.TextMessage;
public class SMSHelper {
public SMSHelper() {
}
public static boolean sendSms(String number, String message) {
boolean result = true;
try {
//sets address to send message
String addr = "sms://" + number;
// opens connection
MessageConnection conn = (MessageConnection) Connector.open(addr);
// prepares text message
TextMessage msg =
(TextMessage) conn.newMessage(MessageConnection.TEXT_MESSAGE);
//set text
msg.setPayloadText(message);
// send message
conn.send(msg);
conn.close();
} catch (SecurityException se) {
// probably the user has not allowed to send sms
// you may want to handle this differently
result = false;
} catch (Exception e) {
result = false;
}
return result;
}
}
Source : http://wiki.forum.nokia.com/index.php/How_to_Send_Text_SMS_in_Java_ME
1 comments:
all about CSS... semangat blogging sob...:)
Post a Comment