简体   繁体   English

无法使用android棒棒糖连接带有wifi的另一个android设备

[英]Can not connect another android device with wifi with android lollipop

Hello, I am trying to connect two android device through wifi. 您好,我正在尝试通过wifi连接两个android设备。 here one device was providing hotspot and another device will connect available wifi. 这里一台设备提供热点,另一台设备将连接可用的wifi。 In here am using following code to connect with wifi 在这里我使用以下代码与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();

The above code is working perfect in lower version and i had problem with android lollipop. 上面的代码在较低版本中工作完美,我在使用Android Lollipop时遇到问题。 with android lollipop i can not connect with wifi, it fallback with previous one, so i am waiting for perfect solution for this issue. 使用android棒棒糖,我无法与wifi连接,它会回退到上一个,因此我正在等待针对此问题的完美解决方案。 thank you. 谢谢。

I was having the same problem, I fixed this problem by updating the API. 我遇到了同样的问题,我通过更新API来解决此问题。 Every Operating system kernel Designer provides API, for Application programmers, that changes from time to time. 每个操作系统内核设计器都为应用程序程序员提供不时更改的API。

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

May these will help for you also. 愿这些也对您有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM