Blackberry:GSM网络下发送短信

Sending SMS in GSM Network using BlackBerry

http://forum.gssdaily.com/viewtopic.php?f=36&t=1671

by tommy » Sat Jun 18, 2011 12:05 pm

Sending SMS in GSM Network using BlackBerry

Code: Select all
import javax.microedition.io.Connector;
   import javax.wireless.messaging.MessageConnection;
   import javax.wireless.messaging.TextMessage;
   
   String addr = "sms://"+number;
   MessageConnection conn = null;
   try {
     conn = (MessageConnection) Connector.open(addr);
     //generate a new text message
     TextMessage msgOut = (TextMessage)conn.newMessage(
           MessageConnection.TEXT_MESSAGE);
     msgOut.setPayloadText(message);
     //finally send our message
     conn.send(msgOut);       
   } catch(Exception e) {
           System.out.println(e.toString());
   } finally {
           try {
             conn.close();
                   conn = null;
           } catch(Exception e){}
   }

你可能感兴趣的:(Blackberry:GSM网络下发送短信)