0

我正在创建一个从 web 服务下载数据的黑莓应用程序,我正在使用以下代码来获取连接

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 时它无法正常工作,请问我还应该使用什么

4

1 回答 1

1

我没有看到运营商 UID 获取代码。但实际上 BIS-B 连接不需要它。“ deviceside=false;ConnectionType=mds-public”应该足够了。

与 BIS-B 相关的代码也在 Direct TCP 部分中。你应该使用CoverageInfo.COVERAGE_BIS_B而不是CoverageInfo.COVERAGE_DIRECT

于 2012-09-26T23:35:16.440 回答