2010-06-07 13 views
3

是否有任何RIM API可用,這將有助於獲取設備的可用網絡服務列表或只有Wi-Fi網絡,併爲任何網絡通信設置選定的網絡接入點?在BlackBerry上掃描可用的Wi-Fi網絡

我的應用程序是否可以禁用GPRS,WAP等移動網絡?

例如:
當應用程序啓動時,即使在設備上沒有設置以前的Wi-Fi網絡接入點並列出可用的Wi-Fi連接,它也應掃描Wi-Fi連接。然後用戶將選擇適當的Wi-Fi連接進行任何網絡通信連接。在應用程序之外,任何互聯網通信(如瀏覽器或任何其他應用程序)都應通過相同的選定Wi-Fi連接完成。 掃描Wi-Fi並設置連接與BlackBerry Wi-Fi設置幾乎相同。

我期待這樣做的BlackBerry OS 4.5,4.7和5.0。

更新

的事情是我在尋找通過應用程序的Wi-Fi掃描功能。就像通過應用程序,我可以掃描可用的Wi-Fi接入點或熱點,並通過選擇設備來設置其中一個接入點,然後連接到該設備進行通信。

基本上就是這樣,我們如何在BlackBerry的「管理連接」中設置Wi-Fi連接?我必須通過應用程序來做類似的事情。

從一些黑莓手機論壇,我才知道有包OS V5.0,即net.rim.device.api.wlan.hotspot包來獲得Wi-Fi熱點。但經過漫長的搜索,我沒有找到任何示例或對它的解釋。正如我試圖通過查看其API文檔來實現的,但我沒有成功。

如果你有任何關於這個或任何示例代碼的想法,這將是非常有益的。

+0

找到你找到一個解決的辦法?我正在尋找關於熱點類的示例代碼,並且正在努力尋找任何代碼。 – Tjaart 2013-04-17 07:41:39

回答

5

那麼,要掃描應用程序的所有可用網絡,您可以使用RIM的NetworkDiagnostic tool

花葯一段代碼掃描您的電話連接,並獲得最佳的連接字符串可以How to reliably establish a network connection on any BlackBerry device

/** 
* Determines what connection type to use and returns the necessary string to use it. 
* @return A string with the connection info 
*/ 
private static String getConnectionString() 
{ 
    // This code is based on the connection code developed by Mike Nelson of AccelGolf. 
    // http://blog.accelgolf.com/2009/05/22/blackberry-cross-carrier-and-cross-network-http-connection 
    String connectionString = null; 

    // Simulator behavior is controlled by the USE_MDS_IN_SIMULATOR variable. 
    if (DeviceInfo.isSimulator()) 
    { 
      if (UploaderThread.USE_MDS_IN_SIMULATOR) 
      { 
        logMessage("Device is a simulator and USE_MDS_IN_SIMULATOR is true"); 
        connectionString = ";deviceside=false"; 
      } 
      else 
      { 
        logMessage("Device is a simulator and USE_MDS_IN_SIMULATOR is false"); 
        connectionString = ";deviceside=true"; 
      } 
    } 

    // Wi-Fi is the preferred transmission method. 
    else if (WLANInfo.getWLANState() == WLANInfo.WLAN_STATE_CONNECTED) 
    { 
     logMessage("Device is connected via Wifi."); 
     connectionString = ";interface=wifi"; 
    } 

    // Is the carrier network the only way to connect? 
    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; 
} 

/** 
* Looks through the phone's service book for a carrier provided BIBS network 
* @return The uid used to connect to that network. 
*/ 
private static String getCarrierBIBSUid() 
{ 
    ServiceRecord[] records = ServiceBook.getSB().getRecords(); 
    int currentRecord; 

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

我運行了RIM NetworkDiagnosticTool,它似乎沒有提供任何可用的多個WiFi網絡列表。我還檢查了源代碼,並沒有看到收集(但不顯示)該信息的任何內容。 – Nate 2012-05-27 22:55:50