Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java HttpConnection没有';我不能使用3G_Java_Blackberry_Java Me_Blackberry Eclipse Plugin_Blackberry Jde - Fatal编程技术网

Java HttpConnection没有';我不能使用3G

Java HttpConnection没有';我不能使用3G,java,blackberry,java-me,blackberry-eclipse-plugin,blackberry-jde,Java,Blackberry,Java Me,Blackberry Eclipse Plugin,Blackberry Jde,我有以下代码: HttpConnection httpCon = null; InputStream fileIn = null; try { httpCon = (HttpConnection) Connector.open(url + getConnectionSuffix(), Connector.READ); httpCon.setRequestMethod(HttpConnection.GET); } catch (Exception e)

我有以下代码:

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

私有字符串getConnectionSuffix()
{
字符串后缀=”;
if(DeviceInfo.isSimulator())
{
connSuffix=“;deviceside=true”;
}
else if((WLANInfo.getWLANState()==WLANInfo.WLAN\u STATE\u CONNECTED)&&
RadioInfo.Arewaf支持(RadioInfo.WAF_WLAN))
{
connSuffix=“;接口=wifi”;
}
其他的
{
字符串uid=null;
ServiceBook sb=ServiceBook.getSB();
ServiceRecord[]records=sb.FindRecordsById(“WPTCP”);
for(int i=0;i

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

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

if((CoverageInfo.getcoveragentatus()&CoverageInfo.COVERAGE_BIS_B)==CoverageInfo.COVERAGE_BIS_B){ connSuffix=“;deviceside=false;ConnectionType=mds public”;
}

请查看此链接您的traget操作系统是什么?如果是5+,则可以使用ConnectionFactory而不是手动检测连接传输。
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;
}