1

I would like to delete or modify an existing wifi configuration. Could someone show me how or point me to the right place?

Thanks

user629126
  • 259
  • 5
  • 14

3 Answers3

1

Not sure, but does this help - http://code.google.com/p/android-wifi-connecter/ ? I found it from https://market.android.com/details?id=com.farproc.wifi.connecter&feature=search_result

Michael Levy
  • 13,097
  • 15
  • 66
  • 100
0

For deleting/forgetting wifi network please try below two links, Android - Cant Remove Wifi Network Programatically- The method removeNetwork(int) in the type WifiManager is not applicable for the arguments (String) and How to forget a wireless network in android programmatically?. And for modifying a particular network I think you should first remove it first and then ask for new password and set it like this :

if(scanResultSecurity.equals(Constants.WEP)){
                                        wifiConfiguration.SSID = "\"" + networkSSID + "\""; 
                                        wifiConfiguration.wepKeys[0] = "\"" + password + "\"";
                                        wifiConfiguration.wepTxKeyIndex = 0;
                                        wifiConfiguration.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
                                        wifiConfiguration.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40);
                                        //Adds to the list of network and returns the network id which can be used to enable it later.
                                        networkId = wifiManager.addNetwork(wifiConfiguration);
                                        if(networkId != -1){
                                            connectToWifi(wifiConfiguration);
                                        }

                                    }
                                    else if(scanResultSecurity.equals(Constants.PSK)){
                                        wifiConfiguration.SSID = "\"" + networkSSID + "\""; 
                                        wifiConfiguration.preSharedKey = "\"" + password + "\"";
                                        wifiConfiguration.hiddenSSID = true;
                                        wifiConfiguration.status = WifiConfiguration.Status.ENABLED;
                                        wifiConfiguration.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
                                        wifiConfiguration.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
                                        wifiConfiguration.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
                                        wifiConfiguration.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);
                                        wifiConfiguration.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);
                                        wifiConfiguration.allowedProtocols.set(WifiConfiguration.Protocol.RSN);
                                        wifiConfiguration.allowedProtocols.set(WifiConfiguration.Protocol.WPA);
                                      //Adds to the list of network and returns the network id which can be used to enable it later.
                                        networkId = wifiManager.addNetwork(wifiConfiguration); 
                                        if(networkId != -1){
                                            connectToWifi(wifiConfiguration);
                                        }
                                    }

private void connectToWifi(WifiConfiguration wifiConfiguration){
        wifiManager.disconnect();
        wifiManager.setWifiEnabled(true);
        boolean enableNetworkBoolean = wifiManager.enableNetwork(wifiConfiguration.networkId, true);
        Log.i(Constants.LOG_TAG, "networkId "+wifiConfiguration.networkId);
        Log.i(Constants.LOG_TAG, "SSID "+wifiConfiguration.SSID);
        Log.i(Constants.LOG_TAG, enableNetworkBoolean+" enableNetworkBoolean");
        boolean reconnectBoolean = wifiManager.reconnect();
        Log.i(Constants.LOG_TAG, reconnectBoolean+" reconnectBoolean");
        boolean changeHappen = wifiManager.saveConfiguration();
        Log.i(Constants.LOG_TAG, changeHappen+" changeHappen");
        if(enableNetworkBoolean && reconnectBoolean && changeHappen){
            Log.i(Constants.LOG_TAG, "Change Happen" );     
//          Utility.showToast(MainActivity.this, Constants.CONNECTED);
            wifiListViewAdapter.notifyDataSetChanged();
        }
        else{
            Log.i(Constants.LOG_TAG, "Change not Happen" );
            Utility.showToast(MainActivity.this, Constants.CONNECTING_ERROR);
        }                   
    }
Community
  • 1
  • 1
Namrata Bagerwal
  • 1,202
  • 13
  • 27