How to connect to WPA_EAP WIFI on Android with 4.3 API
Asked Answered
R

1

12

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.

Rickierickman answered 3/10, 2013 at 22:29 Comment(0)
D
21

You need to set the key management

   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;
Dizzy answered 7/10, 2013 at 23:29 Comment(3)
@Blaine are you able to connect to EAP by using above code ? I am able to save configuration but not able to connect.Multiplier
@sankar Yes, I was about to connect using this. But you also have to use the code that I had above. Combine the two to make the connection.Rickierickman
can we use same for eap of sim type?Dix

© 2022 - 2024 — McMap. All rights reserved.