Android examples for android.net.wifi:Wifi SSID
Check if SSID List Contains Key
import java.util.List; import android.content.Context; import android.net.wifi.ScanResult; import android.net.wifi.WifiManager; public class Main { public static boolean getSSIDListContainsKey(final Context context, String targetSSID) { if (targetSSID == null) return false; List<ScanResult> apList = getScanResults(context); if (apList == null) return false; for (ScanResult ap : apList) { if (ap.SSID.equals(targetSSID)) { return true; }/*w ww .ja v a 2 s . com*/ } return false; } public static List<ScanResult> getScanResults(final Context context) { WifiManager manager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); if (manager.getWifiState() != WifiManager.WIFI_STATE_ENABLED) return null; context.enforceCallingOrSelfPermission(android.Manifest.permission.CHANGE_WIFI_STATE, "need permission: CHANGE_WIFI_STATE"); manager.startScan(); return manager.getScanResults(); } }