android 2.3 wifi (二)

 

7.       Ad hoc的支持

添加ad hoc的支持有两种方式,改wpa_supplicant和改Android Framework wpa_supplicant的原理和方法请参考http://www.xda-developers.com/android/android-ad-hoc-wireless-network-support/, 这种方法不推荐, 不是解决问题的根本。下面是改Android Framework的方法。

Android Framework中添加adhoc支持很简单, 可能只需要改一行代码(当然还没经过测试) 如下:

List<ScanResult> results = mWifiManager.getScanResults();

        if (results != null) {

            for (ScanResult result : results) {

                // Ignore hidden and ad-hoc networks.

                if (result.SSID == null || result.SSID.length() == 0 ||

                        result.capabilities.contains("[IBSS]")) {

                    continue;

                }

 

                boolean found = false;

                for (AccessPoint accessPoint : accessPoints) {

                    if (accessPoint.update(result)) {

                        found = true;

                    }

                }

                if (!found) {

                    accessPoints.add(new AccessPoint(this, result));

                }

            }

        }

上面一段代码在Settings应用的WifiSettings类里发生在wpa_supplicant扫描ap结束时||result.capabilities.contains("[IBSS]")去掉即可支持adhoc

可见google是故意禁了ad hoc的功能。 那么总有原因 下面摘自某论坛

What you say is true - it is relatively easy to support ad-hoc networks. I also appreciate that it sucks if you have to rely on ad-hoc wifi and you own an Android device.
However, there are good reasons as to why Android, or any OS for that matter, doesn't support it.

Ad-hoc networks are i

  • 0
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 6
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值