1

データ接続を確立するための接続を確実に構築するために、次の 2 つの方法を作成しました。これまでのところ、このアプローチをユーザーでテストする際に問題はありませんでした。

このアプローチについてコミュニティからのフィードバックを得て、buildConnectionString() に何か問題があればお知らせください。以下のコードを参照してください。

private static String buildConnectionString()
{

    //The Device is a simultaor --> TCP
    if (DeviceInfo.isSimulator())
        return ";deviceside=true;ConnectionTimeout=20000";

    String st = "";

    //A carrier is providing us with the data service
    if ((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_CARRIER) == CoverageInfo.COVERAGE_CARRIER)
    {

        // blackberry internet service
        ServiceRecord rec = getBIBSRecord();//Apply for BIS access to get info about BIS recordset
        if (rec != null)//couldn't find the right record
            st = "[THIS CONNECTION STRING IS REMOVED, PLEASE APPLY FOR BIS ACCESS TO GET THIS STRING]";
        else if(GetWap2().length() > 0)
            st = GetWap2();
        else
            st = ";deviceside=true";// let the phone try to do the work

    }
    else if ((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_MDS) == CoverageInfo.COVERAGE_MDS)
        st = ";deviceside=false";// use the clients blackberry enterprise server
    else
        st = ";deviceside=true";// let the phone do the work if it can

    return st + ";ConnectionTimeout=45000";
}

public static String GetWap2() {
    String wap2Postfix = null;
    final ServiceBook sb = ServiceBook.getSB();
    final ServiceRecord[] records = sb.findRecordsByCid("WPTCP");

    for (int i = 0; i < records.length; i++) {
        // Search through all service records to find the valid non Wi-Fi
        // WAP 2.0 Gateway Service Record.
        if (records[i].isValid() && !records[i].isDisabled()
                && records[i].getUid() != null
                && records[i].getUid().length() != 0
                && records[i].getUid().toLowerCase().indexOf("wifi") == -1
                && records[i].getUid().toLowerCase().indexOf("mms") == -1) {
            wap2Postfix = ";ConnectionUID=" + records[i].getUid();
            break;
        }//endif
    }//end for
    return wap2Postfix;
}// end wap postfix

考えられる質問:

  • BIS 文字列が存在する (レコードセットが見つかった) 場合、(企業ネットワークによってブロックされることを除けば) 常に機能しますか?
  • WAP2 文字列が存在する (レコードセットが見つかった) 場合、(企業ネットワークによってブロックされることを除けば) 常に機能しますか?
  • キャリア サポートではなく、MDS サポートを最初に確認する必要がありますか?
  • 通信事業者が接続をブロックする極端なケースを超えて、上記のアプローチは機能しますか?

教えて!

4

1 に答える 1

0

このコードを確認してください: http://developerlife.com/tutorials/?p=884

于 2009-12-14T10:00:37.007 に答える