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.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 8
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值