在 BlackBerry 上扫描可用的 Wi-Fi 网络 [英] Scan for available Wi-Fi networks on BlackBerry

查看:20
本文介绍了在 BlackBerry 上扫描可用的 Wi-Fi 网络的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何 RIM API 可以帮助获取可用网络服务列表还是仅用于设备的 Wi-Fi 网络并为任何网络通信设置选定的网络接入点?

Is there any RIM API available which will help to get the list of available network service or only Wi-Fi networks for a device and set selected network access point for any network communications?

我的应用程序是否可以禁用 GPRS、WAP 等移动网络?

Is it possible for my application to disable the mobile networks like GPRS, WAP, etc.?

示例:
当应用程序启动时,它应该扫描 Wi-Fi 连接,即使设备上没有设置以前的 Wi-Fi 网络接入点,并列出可用的 Wi-Fi 连接.然后用户将选择合适的 Wi-Fi 连接来连接任何网络通信.在应用程序之外,任何 Internet 通信,如浏览器或任何其他应用程序,都应通过相同的选定 Wi-Fi 连接完成.扫描 Wi-Fi 并设置连接与 BlackBerry Wi-Fi Setup 几乎相似.

Example:
When the application is started it should scan for Wi-Fi connections, even if there are no previous Wi-Fi network access points set on the device, and list the available Wi-Fi connections. Then the user will select the appropriate Wi-Fi connection to connect for any network communication. Outside the application any Internet communication, like the browser or any other application, should be done through the same selected Wi-Fi connection. The scanning for Wi-Fi and setting the connection is almost similar to BlackBerry Wi-Fi Setup.

我希望为 BlackBerry OS 4.5、4.7 和 5.0 执行此操作.

I am looking to do this for BlackBerry OS 4.5, 4.7 and 5.0.

更新

问题是我正在寻找通过应用程序进行的 Wi-Fi 扫描.就像通过应用程序,我可以扫描可用的 Wi-Fi 接入点或热点,并通过将其选择到设备来设置接入点之一,然后连接到它进行通信.

The thing is I'm looking for Wi-Fi scanning through application. It's like through the application I am able to scan available Wi-Fi access points or hotspots and set one of access point by selecting it to device, then connect to it for communication.

基本上就是这样,我们如何在黑莓的管理连接"中设置 Wi-Fi 连接?我必须通过应用程序做类似的事情.

Basically it's like, how do we set the Wi-Fi connection in "Manage connetion" of BlackBerry? I have to do a similar thing through the applicaiton.

从一些黑莓论坛我了解到 OS v5.0 中有一个包,即net.rim.device.api.wlan.hotspot 包来获取 Wi-Fi 热点.但是经过长时间的搜索,我没有找到任何示例示例或太多解释.因为我试图通过查看其 API 文档来实现,但我没有成功.

From some BlackBerry forums I got to know there is package in OS v5.0, that is, a net.rim.device.api.wlan.hotspot package to get the Wi-Fi hotspots. But after a long search I didn't find any sample example or much explanation on it. As I am trying to implement by looking into its API documentation, but I did not succeded.

如果您对此有任何想法或任何示例代码,这将非常有帮助.

If you have any idea related to this or any sample code it will be very helpful.

推荐答案

好吧,要扫描应用程序的所有可用网络,您可以使用 网络诊断工具来自 RIM.

Well, to scan for all available networks for the application you can use the NetworkDiagnostic tool from RIM.

可以在 如何在任何黑莓设备上可靠地建立网络连接,

/**
 * 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;
}

这篇关于在 BlackBerry 上扫描可用的 Wi-Fi 网络的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆