a_zhon
Code-Porter
采纳率0%
2016-10-08 03:16 阅读 1.5k

Android6.0开启WiFi热点出错

Android6.0开启WiFi热点出错,同样的代码在4.4的系统就可以开启。在6.0就不行。求怎么破!!

 public void createAp() {
        if (mWifiManager.isWifiEnabled()) {
            mWifiManager.setWifiEnabled(false);
        }
        try {
            WifiConfiguration apConfiguration = new WifiConfiguration();
            apConfiguration.SSID = WifiAdmin.SSID;
            apConfiguration.preSharedKey = WifiAdmin.PassWord;
            apConfiguration.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
            Method method = mWifiManager.getClass().getMethod("setWifiApEnabled", WifiConfiguration.class, boolean.class);
            method.invoke(mWifiManager, apConfiguration, true);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

2条回答 默认 最新

  • sky_mine 陈大东 2016-10-08 03:59

    抓log看看是什么错,这段代码是没问题的!

    点赞 评论 复制链接分享
  • a_zhon Code-Porter 2016-10-08 04:31

    图片说明

    点赞 评论 复制链接分享

相关推荐