【发布时间】:2013-10-24 08:06:10
【问题描述】:
我的 BlackBerry 应用程序无法通过 BES 连接到互联网。它通过 Wifi、BIS、GPRS 等成功连接,但未检测到 BES 上的互联网连接。我检查了所有设置,浏览器连接到互联网,但没有连接到应用程序。我的连接方式如下:
static String connectionParameters = "";
public static String checkInternetConnection(){
//String connectionParameters = "";
if(CoverageInfo.getCoverageStatus() == CoverageInfo.COVERAGE_NONE)
{
connectionParameters=null;
}
else
{
if (WLANInfo.getWLANState() == WLANInfo.WLAN_STATE_CONNECTED) {
// Connected to a WiFi access point
connectionParameters = ";interface=wifi";
} else {
int coverageStatus = CoverageInfo.getCoverageStatus();
ServiceRecord record = getWAP2ServiceRecord();
if (record != null
&& (coverageStatus & CoverageInfo.COVERAGE_DIRECT) ==
CoverageInfo.COVERAGE_DIRECT) {
// Have network coverage and a WAP 2.0 service book record
connectionParameters = ";deviceside=true;ConnectionUID="
+ record.getUid();
} else if ((coverageStatus & CoverageInfo.COVERAGE_MDS) ==
CoverageInfo.COVERAGE_MDS) {
// Have an MDS service book and network coverage
connectionParameters = ";deviceside=false";
} else if ((coverageStatus & CoverageInfo.COVERAGE_DIRECT) ==
CoverageInfo.COVERAGE_DIRECT) {
// Have network coverage but no WAP 2.0 service book record
connectionParameters = ";deviceside=true";
}
}
}
return connectionParameters;
}
private static ServiceRecord getWAP2ServiceRecord() {
ServiceBook sb = ServiceBook.getSB();
ServiceRecord[] records = sb.getRecords();
for(int i = 0; i < records.length; i++) {
String cid = records[i].getCid().toLowerCase();
String uid = records[i].getUid().toLowerCase();
if (cid.indexOf("wptcp") != -1 &&
uid.indexOf("wifi") == -1 &&
uid.indexOf("mms") == -1) {
return records[i];
}
}
return null;
}
请帮忙!
编辑:应用程序正在尝试访问 Intranet 上可用的服务器。应用程序无法通过 BES 访问 Internet(谷歌网络服务)和 Intranet(本地服务器)。有人可以评论吗?
【问题讨论】:
-
您正在为哪个版本的黑莓操作系统开发? docs.blackberry.com/en/developers/deliverables/11938/… 表示涉及防火墙技术,也许您的服务不被允许?您是否正在尝试连接到网络服务器?
-
我为 OS 6 及更高版本开发。是的,该应用程序尝试连接到 Web 服务。如何验证其防火墙设置或连接方法是否存在问题?
-
@Sarah BES 管理员可以使用 IT 策略禁止某些设备连接到互联网。 BES 连接意味着您可以连接到 BES 公司网络(将其视为 LAN)。无论如何尝试用
CoverageInfo.isCoverageSufficient替换标志检查。 -
@Sarah 您的代码容易出现错误,使用标志来检查覆盖率并将后缀附加到 URL。那是建立联系的旧方法,不再是推荐的方法。考虑使用新的
ConnectionFactory类。这是simple tutorial。 -
@Sarah - BES 包含在您使用的方法中 - 在您称之为 MDS 的代码中。 BISB 有所不同,您的代码不使用它。我推荐这个文档让你更好地理解你的代码试图做什么:developer.blackberry.com/bbos/java/documentation/…。您还将在那里看到如何访问 BISB。如果您不希望采用史密斯先生推荐的方法,请说明当应用程序连接失败时您尝试使用的连接方法。我敢打赌这不是 BES。
标签: blackberry connection internet-connection