I want to create Access Point in android programmatically with the following configurations.
AccessPointName :SomeName
Security:WPA2 PSK
Password
I was also facing same problem by passing 4 as KeyMangement solved my problem.
WifiConfiguration myConfig = new WifiConfiguration();
myConfig.SSID = ssid; // SSID name of netwok
myConfig.preSharedKey = password; // password for network
myConfig.allowedKeyManagement.set(4); // 4 is for KeyMgmt.WPA2_PSK which is not exposed by android KeyMgmt class
myConfig.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN); // Set Auth Algorithms to open
try {
Method method = mWifiManager.getClass().getMethod("setWifiApEnabled", WifiConfiguration.class, boolean.class);
return (Boolean) method.invoke(mWifiManager, myConfig, true); // setting and turing on android wifiap with new configrations
} catch (Exception e) {
e.printStackTrace();
}
Read more at Link