Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void saveWepConfig()
- {
- WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
- WifiConfiguration wc = new WifiConfiguration();
- wc.SSID = "\"SSID_NAME\""; //IMP! This should be in Quotes!!
- wc.hiddenSSID = true;
- wc.status = WifiConfiguration.Status.DISABLED;
- wc.priority = 40;
- wc.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
- wc.allowedProtocols.set(WifiConfiguration.Protocol.RSN);
- wc.allowedProtocols.set(WifiConfiguration.Protocol.WPA);
- wc.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN);
- wc.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.SHARED);
- wc.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);
- wc.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);
- wc.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40);
- wc.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP104);
- wc.wepKeys[0] = "\"aaabbb1234\""; //This is the WEP Password
- wc.wepTxKeyIndex = 0;
- WifiManager wifiManag = (WifiManager) this.getSystemService(WIFI_SERVICE);
- boolean res1 = wifiManag.setWifiEnabled(true);
- int res = wifi.addNetwork(wc);
- Log.d("WifiPreference", "add Network returned " + res );
- boolean es = wifi.saveConfiguration();
- Log.d("WifiPreference", "saveConfiguration returned " + es );
- boolean b = wifi.enableNetwork(res, true);
- Log.d("WifiPreference", "enableNetwork returned " + b );
Add Comment
Please, Sign In to add comment