如何使用4.3 API连接到Android上的WPA_EAP WIFI [英] How to connect to WPA_EAP WIFI on Android with 4.3 API

查看:479
本文介绍了如何使用4.3 API连接到Android上的WPA_EAP WIFI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,Android添加了使用API​​ 18(JellyBean 4.3)连接到EAP WIFI的功能。我已经找了很多例子,但找不到任何例子,我也无法连接我的代码。一切似乎按预期工作,但实际连接似乎不起作用。

Recently Android added the ability to connect to EAP WIFI with API 18 (JellyBean 4.3). I have looked for a number of examples, but can't find any examples, and I can't get my code to connect. Everything appears to work as expected, but making the actual connection doesn't seem to work.

以下是我正在做的事情:

Here is what I'm doing:

Log.d( "WiFi", "adding network via Android Enterprise Config with SSID: " + ssid );
                    WifiEnterpriseConfig enterpriseConfig = new WifiEnterpriseConfig(); 
                    wifiConfig = new WifiConfiguration();
                    wifiConfig.SSID = ssid; 

                    enterpriseConfig.setIdentity(userName);
                    enterpriseConfig.setPassword(passWord);
                    enterpriseConfig.setEapMethod(WifiEnterpriseConfig.Eap.PEAP); 
                    wifiConfig.enterpriseConfig = enterpriseConfig;
                    Log.i("WIFI", "My wifi"+ wifiConfig.status); 
                    networkId = wfm.addNetwork(wifiConfig);

                    wfm.enableNetwork(networkId, true); // this initiates the connection

无论出于何种原因,都没有建立连接。似乎其他一切设置正确。如果我遗漏了任何东西,请告诉我,我很乐意添加它。

For whatever reason the connection isn't made. It appears that everything else is set correctly. If I've left anything out, let me know and I'll happily add it.

我们非常感谢任何帮助或指示。

Any help or direction would be greatly appreciated.

推荐答案

你需要设置密钥管理

   WifiEnterpriseConfig enterpriseConfig = new WifiEnterpriseConfig(); 
   wifiConfig = new WifiConfiguration();
   wifiConfig.SSID = ssid; 
   wifiConfig.allowedKeyManagement.set(KeyMgmt.WPA_EAP);
   wifiConfig.allowedKeyManagement.set(KeyMgmt.IEEE8021X);
   enterpriseConfig.setIdentity(userName);
   enterpriseConfig.setPassword(passWord);
   enterpriseConfig.setEapMethod(WifiEnterpriseConfig.Eap.PEAP); 
   wifiConfig.enterpriseConfig = enterpriseConfig;

这篇关于如何使用4.3 API连接到Android上的WPA_EAP WIFI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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