private static void changeNetworkWPA ( WifiManager wifiManager , WifiParsedResult wifiResult ) { WifiConfiguration config = changeNetworkCommon ( wifiResult ) ; // Hex passwords that are 64 bits long are not to be quoted. config . preSharedKey = quoteNonHex ( wifiResult . getPassword ( ) , 64 ) ; config . allowedAuthAlgorithms . set ( WifiConfiguration . AuthAlgorithm . OPEN ) ; config . allowedProtocols . set ( WifiConfiguration . Protocol . WPA ) ; // For WPA config . allowedProtocols . set ( WifiConfiguration . Protocol . RSN ) ; // For WPA2 config . allowedKeyManagement . set ( WifiConfiguration . KeyMgmt . WPA_PSK ) ; config . allowedKeyManagement . set ( WifiConfiguration . KeyMgmt . WPA_EAP ) ; config . allowedPairwiseCiphers . set ( WifiConfiguration . PairwiseCipher . TKIP ) ; config . allowedPairwiseCiphers . set ( WifiConfiguration . PairwiseCipher . CCMP ) ; config . allowedGroupCiphers . set ( WifiConfiguration . GroupCipher . TKIP ) ; config . allowedGroupCiphers . set ( WifiConfiguration . GroupCipher . CCMP ) ; updateNetwork ( wifiManager , config ) ; }
Adding a WPA or WPA2 network