Blackberry 创建http的四种方式

一.获取当前手机支持的接入方式

public void initializeTransportAvailability() {
		ServiceBook sb = ServiceBook.getSB();
		ServiceRecord[] records = sb.getRecords();

		for (int i = 0; i < records.length; i++) {
			ServiceRecord myRecord = records[i];
			String cid, uid;

			if (myRecord.isValid() && !myRecord.isDisabled()) {
				cid = myRecord.getCid().toLowerCase();
				uid = myRecord.getUid().toLowerCase();
				// BIS
				if (cid.indexOf("ippp") != -1 && uid.indexOf("gpmds") != -1) {
					srBIS = myRecord;
				}
				// WIFI
				if (cid.indexOf("wptcp") != -1 && uid.indexOf("wifi") != -1) {
//					srWiFi = myRecord;
				}
				// Wap2.0
				if (cid.indexOf("wptcp") != -1 && uid.indexOf("wifi") == -1
						&& uid.indexOf("mms") == -1) {
					srWAP2 = myRecord;
				}
			}
		}
		if (CoverageInfo.isCoverageSufficient(CoverageInfo.COVERAGE_BIS_B)) {
			coverageBIS = true;
		}
		if (CoverageInfo.isCoverageSufficient(CoverageInfo.COVERAGE_DIRECT)) {
			coverageTCP = true;
			coverageWAP2 = true;
		}
		if (WLANInfo.getWLANState() == WLANInfo.WLAN_STATE_CONNECTED) {
			coverageWiFi = true;
		}
		if (CoverageInfo.isCoverageSufficient(CoverageInfo.COVERAGE_DIRECT)) {
			coverageTCP = true;
		}
	}

 二.wifi方式创建http

        HttpConnection httpConnection =null;
	String httpurl = url+";interface=wifi"
	httpConnection = (HttpConnection) Connector.open(httpUrl,
					Connector.READ_WRITE);

 

  三 BIS方式创建http

 

	
        HttpConnection httpConnection =null;
	String bisUid = srBIS.getUid();
	String httpurl = url+";deviceside=false;connectionUID="
					+ bisUid + ";ConnectionType=mds-public";
	httpConnection = (HttpConnection) Connector.open(httpUrl,
					Connector.READ_WRITE);
 

  四 WAP2方式创建http

 

	HttpConnection httpConnection =null;
	String wap2Uid = srWAP2.getUid();
	String httpurl = ";deviceside=true" + ";ConnectionUID="
						+ wap2Uid;
	httpConnection = (HttpConnection) Connector.open(httpUrl,
					Connector.READ_WRITE);

 五 直连方式创建http

 

	HttpConnection httpConnection =null;
	String httpurl = ";deviceside=true"
	httpConnection = (HttpConnection) Connector.open(httpUrl,
					Connector.READ_WRITE);

 

此外还有BES,Unite,WAP1等方式,因为无法测试就不写了。以为四种方式都测试可行。

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值