我的黑莓应用程序有问题。实际上,我开发了一个黑莓聊天应用程序,使用第三方服务器进行即时消息传递以及一些用于 Web 服务调用的代码。
该应用程序在 WIFI 网络上运行良好,但是当我尝试在运营商网络上运行该应用程序时,它显示
服务器认证失败
这是连接字符串的代码:
public static String getConnectionString() {
String connectionString = "";
if (DeviceInfo.isSimulator()) {
if (USE_MDS_IN_SIMULATOR) {
connectionString = ";deviceside=false";
} else {
connectionString = ";deviceside=true";
}
}
else if ((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_DIRECT) == CoverageInfo.COVERAGE_DIRECT) {
String carrierUid = getCarrierBIBSUid();
if (carrierUid == null) {
// Has carrier coverage, but not BIBS. So use the carrier's TCP
// network
connectionString = ";deviceside=true";
} else {
connectionString = ";deviceside=false;connectionUID=" + carrierUid + ";ConnectionType=mds-public";
}
}
else if ((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_MDS) == CoverageInfo.COVERAGE_MDS) {
connectionString = ";deviceside=false";
}
else if (CoverageInfo.getCoverageStatus() == CoverageInfo.COVERAGE_NONE) {
}
else {
connectionString = ";deviceside=true";
}
if ((RadioInfo.getActiveWAFs() & RadioInfo.WAF_WLAN) != 0
&& WLANInfo.getWLANState() == WLANInfo.WLAN_STATE_CONNECTED) {
connectionString += ";interface=wifi";
}
connectionString += ";ConnectionTimeout=30000";
return connectionString;
}
这是获取BIS 运营商的代码:
public static String getCarrierBIBSUid() {
ServiceRecord[] records = ServiceBook.getSB().getRecords();
int currentRecord;
try{
for (currentRecord = 0; currentRecord < records.length; currentRecord++) {
if (records[currentRecord].getCid().toLowerCase().equals("ippp")) {
if (records[currentRecord].getName().toLowerCase().indexOf("bibs") >= 0) {
return records[currentRecord].getUid();
}
}
}
}catch (Exception e) {
}
return null;
}