gpt4 book ai didi

java - HttpConnection 不适用于 3G

转载 作者:行者123 更新时间:2023-12-01 15:14:26 26 4
gpt4 key购买 nike

我有以下代码:

HttpConnection httpCon = null;
InputStream fileIn = null;
try
{
httpCon = (HttpConnection) Connector.open(url + getConnectionSuffix(), Connector.READ);
httpCon.setRequestMethod(HttpConnection.GET);
}
catch (Exception e)
{
.......
}
.............

private String getConnectionSuffix()
{
String connSuffix = "";
if (DeviceInfo.isSimulator())
{
connSuffix = ";deviceside=true";
}
else if ( (WLANInfo.getWLANState() == WLANInfo.WLAN_STATE_CONNECTED) &&
RadioInfo.areWAFsSupported(RadioInfo.WAF_WLAN))
{
connSuffix=";interface=wifi";
}
else
{
String uid = null;
ServiceBook sb = ServiceBook.getSB();
ServiceRecord[] records = sb.findRecordsByCid("WPTCP");
for (int i = 0; i < records.length; i++)
{
if (records[i].isValid() && !records[i].isDisabled())
{
if (records[i].getUid() != null &&
records[i].getUid().length() != 0)
{
if ((records[i].getCid().toLowerCase().indexOf("wptcp") != -1) &&
(records[i].getUid().toLowerCase().indexOf("wifi") == -1) &&
(records[i].getUid().toLowerCase().indexOf("mms") == -1))
{
uid = records[i].getUid();
break;
}
}
}
}
if (uid != null) {
// WAP2 Connection
connSuffix = ";ConnectionUID="+uid;
} else {
connSuffix = ";deviceside=true";
}
}
return connSuffix;
}

但是互联网并不总是有效。在 3G 上它不起作用(其他应用程序,例如:浏览器运行良好)。怎么了?

最佳答案

在获取服务 Book 之前,尝试通过 BIS 连接(如果 Blackberry 选项打开则使用):

if ((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_BIS_B) == CoverageInfo.COVERAGE_BIS_B) { connSuffix = ";deviceside=false;ConnectionType=mds-public"; }

关于java - HttpConnection 不适用于 3G,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11828822/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com