1

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.

adeous
  • 113
  • 1
  • 8
  • could you post some code excerpts where you create it and trying to connect to it. thank you. – Sergey Benner Jan 16 '12 at 16:49
  • [here][1] you will get your answer. It helped me also. [1]: http://stackoverflow.com/questions/8818290/how-to-connect-to-a-specific-wifi-network-in-android-programmatically – Ashher Alam Jun 24 '13 at 11:57

2 Answers2

1
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />    
Heather McVay
  • 939
  • 3
  • 15
  • 31
0

This is the correct form of this setting:

wifiConfiguration.SSID = "\"" + networkSSID + "\"";

Stuart Siegler
  • 1,686
  • 4
  • 30
  • 38