I have a problem when I want to connect my device to an existing network wifi.
That is the situation:
I am looking to an existing configured network, if there is not the one I am looking for I build it and then I try to connect the phone.
When the wifi configuration is built manually using the phone interface, I can find it and then connect to it. But when I tried to build the configuration programmaticly Android cannot connect the phone to the network.
I have got the following message : "Association request to the driver failed".
I am wondering if the association that failed is the association between the scanned network and the configurated network. BUt I don't know why and so I don't know how to manage this problem.
EDIT: And I forget to say, that my WifiConfiguration is exactly the same as the one is created manually because I get the info from the conf with some logs.
EDIT2 : Here is my wificonf (network is protected by a wep key) :
WifiConfiguration wifiConf = new WifiConfiguration(); wifiConf.SSID = "\"ssid\""; wifiConf.wepKeys[0] = "\"password\""; wifiConf.wepTxKeyIndex = 0; wifiConf.hiddenSSID = false; wifiConf.status = WifiConfiguration.Status.DISABLED; wifiConf.priority = 40; wifiConf.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN); wifiConf.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.SHARED); wifiConf.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40); wifiConf.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP104); wifiConf.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);//+ wifiConf.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);//+ wifiConf.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE); wifiConf.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP); wifiConf.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP); wifiConf.allowedProtocols.set(WifiConfiguration.Protocol.RSN); wifiConf.allowedProtocols.set(WifiConfiguration.Protocol.WPA);
EDIT3 : I already add the permission in AndroidManifest :
uses-permission android:name="android.permission.ACCESS_WIFI_STATE" uses-permission android:name="android.permission.UPDATE_DEVICE_STATS" uses-permission android:name="android.permission.CHANGE_WIFI_STATE"
I hope my problem is clear and hope too that someone could help me.