I'm running a small App that scans for available WLAN networks via WifiManager.startScan() / WifiReceiver. As soon as a specific open network is detected I try to connect to it by calling this code:
WifiConfiguration wifiConfig = new WifiConfiguration();
wifiConfig.BSSID =result.BSSID; // BSSID of detected network
wifiConfig.priority = 1;
wifiConfig.allowedKeyManagement.set(KeyMgmt.NONE);
wifiConfig.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
wifiConfig.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN);
wifiConfig.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
wifiConfig.status=WifiConfiguration.Status.ENABLED;
int netId = scanData.wifiManager.addNetwork(wifiConfig);
scanData.wifiManager.enableNetwork(netId, true);
The strange thing here: on my tablet and on some other users smartphones Android crashes! To be clear: it is not my App that fails, the whole device reboots! So what could be the reason for that? Does anybody know a workaround for this problem? Or is there something wrong with my method to connect to a network?
Thanks!
Elmi
OK, it seems like this problem can't be solved out of an Android App itself since it is a problem of the underlying firmware. This problem appeared with one of these crappy Archos tablets (wich are trash in general). Exactly the same code now works without any problems on a Motorola Xoom 2.