get Existing Wifi - Android android.net.wifi

Android examples for android.net.wifi:Wifi Property

Description

get Existing Wifi

Demo Code

import java.util.List;

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

public class Main {

  public static WifiConfiguration getExistingWifi(WifiManager wifiManager, String ssid) {
    List<WifiConfiguration> netWorkList = wifiManager.getConfiguredNetworks();
    if (netWorkList == null) {
      return null;
    }/* w w w.  j a  va  2s .  c  o m*/
    String realSSID = "\"" + ssid + "\"";
    for (WifiConfiguration wifi : netWorkList) {
      if (wifi != null && realSSID.equals(wifi.SSID)) {
        return wifi;
      }

    }
    return null;
  }

}

Related Tutorials