remove Network by SSID - Android android.net.wifi

Android examples for android.net.wifi:Wifi SSID

Description

remove Network by SSID

Demo Code

import java.util.List;

import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiManager;
import android.util.Log;

public class Main{

    private static final String TAG = "WifiUtils";
    public static void removeNetwork(String ssid, WifiManager wifiManager) {
        List<WifiConfiguration> list = wifiManager.getConfiguredNetworks();
        if (list == null)
            return;
        for (WifiConfiguration i : list) {
            Log.d(TAG, i.SSID + " " + i.BSSID);
            if (i.SSID != null && i.SSID.equals("\"" + ssid + "\"")) {
                wifiManager.removeNetwork(i.networkId);
            }/* w  w w .  ja  v  a 2s. c om*/
        }

    }

}

Related Tutorials