SmsDemo短信例子程序说明

SmsDemo短信例子程序说明 


今天测试了黑莓开发工具内置的SmsDemo例子程序,这是一个非常好的短信收发程序例子。


 


导入方法:


eclipse开发工具 菜单 File -> Import -> Import BlackBerry Samples


 


SmsDemo可以发送短信给手机Inbox,也可以发送短信给手机特定端口,可以收短信,收特定端口3590的短信。


使用方法:
启动程序后,提示 Send messages to inbox?


如果选择 是 ,短信将发到对方手机的短信inbox里面(端口0)。
   如果对方手机也运行着这个程序,将提示:
    Received:
    Destination: sms://+86 13812340000
    Data:
    xxxx 


  如果选择 否,短信将发到对方的手机 的端口3590上面。
 此时: The smsdemo only captures incoming SMS messages sent to port 3590, meaning it'll ignore messages sent to any other port.
如果对方手机也运行着这个程序,将提示:
    Received:
    Destination: sms://+86 13812340000:3590
    Data:
    xxxx 


注意事项:
如果机器上有其他程序监听了0端口(比如Labi),那么将报错:
net.rim.device.api.io.IOPortAlreadyBoundException: SMS Port already in use


reference:
http://supportforums.blackberry.com/t5/Java-Development/Unread-SMS-Catch-SMS/m-p/19137


http://supportforums.blackberry.com/t5/Java-Development/Problem-in-sending-SMS-through-simulator/m-p/255710?jump=true 


http://supportforums.blackberry.com/t5/Java-Development/Deleting-Intercepted-SMS/m-p/20308


http://supportforums.blackberry.com/t5/Java-Development/PushRegistry-port-already-in-use/td-p/30303




ZERO is the default SMS port. If you open the connection on port 0, it will read SMS that are suppose to appear in the Inbox.
 Use of "sms://:" with Connector.open() will cause the error  "java.lang.IllegalArgumentException: Illegal opening string"
 Use of "sms://"  with Connector.open() will cause the error  "Operation not permitted on a Client Connection"
 Use of "sms://:0" with Connector.open() will work as desired.


 

你可能感兴趣的:(eclipse,手机,import,开发工具,BlackBerry,sms)