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

查看:225
本文介绍了扫描黑莓可用的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连接,即使是设备上设置没有previous Wi-Fi网络接入点,并列出可用的Wi-Fi连接。然后,用户将选择合适的Wi-Fi连接来连接任何网络通信。应用程序的任何互联网传播外,像浏览器或任何其他应用程序,应通过同一个选择的Wi-Fi连接完成。
支持Wi-Fi扫描和设置连接几乎类似于黑莓Wi-Fi设置。

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.

我期待黑莓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文档来实现,但我没有succeded。

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.

如果您有与此相关的或任何样本$ C $任何想法c那么它会有很大的帮助。

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

推荐答案

好吧,扫描所有可用的网络应用程序,你可以使用从RIM NetworkDiagnostic工具

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

花药件code的扫描您的电话连接,并获得最佳的连接字符串可以的 <一个找到href=\"http://www.localytics.com/blog/post/how-to-reliably-establish-a-network-connection-on-any-blackberry-device\"相对=nofollow>如何可靠地建立任何BlackBerry设备上的网络连接

Anther piece of code to scan for your phone connectivity and get the best connection string can be found in 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;
}

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

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