随笔 - 2, 文章 - 73, 评论 - 60, 引用 - 0
数据加载中……

blackberry--黑莓联网开发各种联网模板型[转载]

最近开发黑莓的应用程序,牵涉到联网部分。在这过程中遇到了很多问题,也查找了很多资料。很有感触。于是总结了一份黑莓联网开发中的各种方式,只是一个模板性的。在开发过程中只有具体问题具体分析了。我也是为了方便不容易忘记,所以写进博客。希望能记住:

黑幕目前联网主要有几种方式:

1、WAP 2.0

2、WAP1.0/1.1

3、Wi-Fi

4、BlackBerry Mobile Data Service

5、Direct TCP

6、BlackBerry Internet Service

下面简单说一下几种代码的接口,不一定是必须的,不过如果连不起网的时候可以尝试一下,这事官方网址一个视频找到的官方代码,仅供参考:

1、Using WAP 2.0:

  - Append ";ConnectionUID=xyz" with corresponding UID for WAP 2.0 Service Book(WPTCP)

  需要在联网的url后面跟接";ConnectionUID=xyz",xyz为WAP2.0 (WPTCP) 绑定的UID,例如:

  HttpConncetion conn = (HttpConncetion) Connector.open("http://www.blackberry.com;deviceside=true;ConnectionUID=WAP2");

2、Using WAP 1.0/1.1:

 - Append ";WapGatewayIP=127.0.0.1;WapGatewayPort=9201;WapGatewayAPN=myapn.net"

  需要在联网的后面跟接"WapGatewayIP=127.0.0.1;WapGatewayPort=9201;WapGatewayAPN=myapn.net",例如:

HttpConnection conn = (HttpConnection) Connector.open("http://www.blackberry.com;deviceside=true;WapGatewayIP=195.115.025.129;WapGatewayPort=9201;WapGatewayAPN=wapsfr");

3、Using Wi-Fi:

   - Append ";interface=wifi" for explicit connections

  - Wi-Fi connectivity happens automatically for BlackBerry MDS and BlackBerry Internet Service-B connections

  需要为你的详细连接跟接";interface=wifi",例如:

 HttpConnection conn =  (HttpConncetion) Connector.open("http://www.blackberry.com;interface=wifi");

4、Using BlackBerry MDS

  - Append ";deviceside=false" for expilit connections

  - Default connection is no parameters specified

 

  Default Connection Example:

  HttpConncetion conn = (HttpConncetion) Connector.open("http://www.blackberry.com");

  Explicit MDS Connection - Automatic Service Book Selection:

  HttpConncetion conn = (HttpConncetion) Connector.open("http://www.blackberry.com;deviceside=false");

 

  Explicit MDS Connection - Manual Service Book Selection:

  HttpConncetion conn = (HttpConncetion) Connector.open("http://www.blackberry.com;deviceside=false;ConnectionUID=S109234");

5、Using Direct TCP

  - Requires some intelligence by the user or developer to specify APN

  - Append ";deviceside=true"

  - More and more carriers hardcode APN info in the branding data

  a)   Automatic APN Selection:

  HttpConncetion conn = (HttpConncetion) Connector.open(http://www.blackberry.com;deviceside=true);

  b)   Manual APN Secletion:

  HttpConncetion conn = (HttpConncetion) Connector.open("http://www.blackberry.com;deviceside=true;apn=internet.com");

  c)   Manual APN Selection with Authentication:

    HttpConncetion conn = (HttpConncetion) Connector.open("http://www.blackberry.com;deviceside=true;apn=wap.cingular;TunnelAuthUsername=WAP@CINGULARGPRS.COM;TunnelAuthPassword=CINGULAR1");

  另外附加一种socket的方式:

  d)  (StreamConnection) Connector.open("socket://testserver:600;deviceside=true");

6、Using BlackBerry Internet Service

   这个好像需要是Blackberry联盟成员,需要批准,对这个相关信息可以见:http://na.blackberry.com/eng/partners/alliance.jsp

  以上就是简单的总结了这些。具体的问题只有开发中具体分析。欢迎莓友们讨论。

注:以上参数之间需要用分号隔开,附带一份以上出现的一些参数解释:

Parameter
 Description
 
WapGatewayIP
 IP address of the gateway.
 
WapGatewayAPN
 APN for General Packet Radio Service (GPRS) networks only. For testing purposes, you can use rim.net.gprs
 
WapGatewayPort
 Gateway port value. If port 9203 is specified, Wireless Transport Layer Security (WTLS) is used unless WapEnableWTLS=false is specified.
 
WapSourceIP
 IP address of the source.
 
WapSourcePort
 Source port value.
 
TunnelAuthUsername
 User name for APN session, when Password Authentication Protocol (PAP) or Challenge Handshake Application Protocol (CHAP) authentication is used.
 
TunnelAuthPassword
 Password for APN session, when PAP or CHAP authentication is used.
 
WapEnableWTLS
 Explicitly turns on or turns off WTLS. If this parameter is not specified, WTLS is used by default for connections to port 9203.
 

 

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/lyerliu/archive/2010/02/01/5277446.aspx

posted on 2010-06-08 09:42 郭天文 阅读(458) 评论(0)  编辑 收藏 引用 所属分类: BlackBerry


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理