我正在创建一个从webservices下载数据的黑莓应用程序, 我正在使用以下代码来获取连接
public static String getConnectionString()
{
String connectionString = null;
if(DeviceInfo.isSimulator())
{
connectionString = ";deviceside=true";
}
else if(WLANInfo.getWLANState() == WLANInfo.WLAN_STATE_CONNECTED)
{
connectionString = ";interface=wifi";
}
else if((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_DIRECT) == CoverageInfo.COVERAGE_DIRECT)
{
//logMessage("Carrier coverage.");
String carrierUid = getCarrierBIBSUid();
if(carrierUid == null)
{
// Has carrier coverage, but not BIBS. So use the carrier's TCP network
// logMessage("No Uid");
connectionString = ";deviceside=true";
}
else
{
// otherwise, use the Uid to construct a valid carrier BIBS request
//logMessage("uid is: " + carrierUid);
connectionString = ";deviceside=false;connectionUID="+carrierUid + ";ConnectionType=mds-public";
}
}
// Check for an MDS connection instead (BlackBerry Enterprise Server)
else if((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_MDS) == CoverageInfo.COVERAGE_MDS)
{
// logMessage("MDS coverage found");
connectionString = ";deviceside=false";
}
// If there is no connection available abort to avoid bugging the user unnecssarily.
else if(CoverageInfo.getCoverageStatus() == CoverageInfo.COVERAGE_NONE)
{
//logMessage("There is no available connection.");
}
// In theory, all bases are covered so this shouldn't be reachable.
else
{
//logMessage("no other options found, assuming device.");
connectionString = ";deviceside=true";
}
return connectionString;
}
但是它在Wifi上工作,但是当我使用3G时它不起作用, 请说明我还应该使用其他什么
答案 0 :(得分:1)
我没有看到运营商UID获取代码。但实际上你不需要它用于BIS-B连接。 “deviceside = false; ConnectionType = mds-public”应该足够了。
与BIS-B相关的代码也在Direct TCP部分内。您应该使用CoverageInfo.COVERAGE_BIS_B
代替CoverageInfo.COVERAGE_DIRECT