2011-07-15 9 views
0

以下のコードを使用して、自分のHTTPコールの接続パラメータを取得します。ブラックベリーでアクティブな接続を取得する

テスト用の電話機とエミュレータで動作します。しかし、一部の人々(おそらく9700ユーザー、それは保証できません)では、動作可能な3G /無線LAN接続がある場合でも、"Failed to transmit"のエラーが発生します。

私は間違っていますか?

private String getConnectionParameters() 
    { 
    String strCP = null;   

    int coverageStatus = CoverageInfo.getCoverageStatus(); 

    if((coverageStatus & CoverageInfo.COVERAGE_DIRECT) == CoverageInfo.COVERAGE_DIRECT) 
    { 
     // Carrier coverage 
     String carrierUid = getCarrierBIBSUid(); 
     if(carrierUid == null) 
     { 
     String wap2 = getWAP2ServiceRecord(); 

     if (wap2 != null) 
     { 
      // Try using WAP2 
      strCP = ";deviceside=false;connectionUID="+wap2; 
     } 
     else 
     { 
      // Has carrier coverage, but not BIBS or WAP2. So use the carrier's TCP network 
      strCP = ";deviceside=true"; 
     } 
     } 
     else 
     { 
     // otherwise, use the Uid to construct a valid carrier BIBS request 
     strCP = ";deviceside=false;connectionUID="+carrierUid + ";ConnectionType=mds-public"; 
     } 
    } 
    else if((coverageStatus & CoverageInfo.COVERAGE_MDS) == CoverageInfo.COVERAGE_MDS) 
    { 
     // MDS coverage found 
     strCP = ";deviceside=false"; 
    } 
    else if((WLANInfo.getWLANState() == WLANInfo.WLAN_STATE_CONNECTED) && RadioInfo.areWAFsSupported(RadioInfo.WAF_WLAN)) 
    { 
     // Device is connected via Wifi 
     strCP = ";interface=wifi"; 
    } 
    else if(coverageStatus == CoverageInfo.COVERAGE_NONE) 
    { 
     // There is no available connection 
     strCP = ""; 
    } 
    else 
    { 
     // no other options found, assuming device 
     strCP = ";deviceside=true"; 
    } 

    return strCP; 
    } 

    private String getCarrierBIBSUid() 
    { 
    ServiceRecord[] records = ServiceBook.getSB().getRecords(); 

    for(int i = 0; i < records.length; i++) 
    { 
     if(records[i].getCid().toLowerCase().equals("ippp")) 
     { 
     if(records[i].getName().toLowerCase().indexOf("bibs") >= 0) 
     { 
      return records[i].getUid(); 
     } 
     } 
    } 

    return null; 
    } 

    private String 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].getUid(); 
     } 
    } 

    return null; 
    } 

答えて

0

私はVersatile Monkey connection code

私の問題は、あなたがループする必要があり、各接続を試し、BIS接続していた見つける前、私は私の接続クラスと同じ問題がありました。それがキャリアのものか、CDMA対GSMのものかどうかは分かりません。

+0

私はそれぞれの接続を試す必要はありませんが、それは非常に便利です、ありがとう! –

+0

デバイスのAPN設定にもなります。 TCPはそれが動作すると言えるかもしれませんが、もしユーザーがAPNの設定をしていなければ:(これも数回もありました!) – coryjacobsen

+0

私はそれをチェックします。問題はT-MobileのBold 9700これはかなり奇妙です。 –

関連する問題