【问题标题】:Can not connect another android device with wifi with android lollipop无法使用 android lollipop 连接另一个 android 设备与 wifi
【发布时间】:2015-07-21 19:37:49
【问题描述】:

您好,我正在尝试通过 wifi 连接两个 android 设备。这里一个 设备正在提供热点,另一台设备将连接可用 无线上网。在这里我使用以下代码连接wifi

mainWifi = (WifiManager)device_list.this. getSystemService(Context.WIFI_SERVICE);
mainWifi.setWifiEnabled(true);
mainWifi.startScan();
 WifiConfiguration wifiConfig = new WifiConfiguration();




        wifiConfig.SSID = sr.SSID;
        wifiConfig.status = WifiConfiguration.Status.ENABLED;


        wifiConfig.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
        wifiConfig.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
        wifiConfig.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
        wifiConfig.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);
        wifiConfig.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);
        wifiConfig.allowedProtocols.set(WifiConfiguration.Protocol.RSN);
        wifiConfig.priority = 40;


        netId = mainWifi.addNetwork(wifiConfig);

            mainWifi.disconnect();
            mainWifi.enableNetwork(netId, true);
            mainWifi.reconnect();

上面的代码在低版本中运行完美,但我遇到了问题 与安卓棒棒糖。使用 android 棒棒糖我无法连接 wifi,它回退到以前的,所以我在等待完美 这个问题的解决方案。谢谢。

【问题讨论】:

标签: android wifi


【解决方案1】:

我遇到了同样的问题,我通过更新 API 解决了这个问题。 每个操作系统内核设计器都为应用程序程序员提供不时更改的 API。

https://developer.android.com/about/versions/android-5.0.html https://developer.android.com/about/versions/android-5.0-changes.html

希望这些对你也有帮助。

【讨论】:

  • 虽然此链接可能会回答问题,但最好在此处包含答案的基本部分并提供链接以供参考。如果链接页面发生更改,仅链接的答案可能会失效。
猜你喜欢
  • 2021-02-12
  • 2012-01-16
  • 1970-01-01
  • 2016-08-18
  • 2017-10-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多