Android examples for android.net.wifi:Wifi Scan
get WiFi Scan Results and enforce Permission to change wifi state
import java.util.List; import android.content.Context; import android.net.wifi.ScanResult; import android.net.wifi.WifiManager; public class Main{ 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();/* w w w . j av a 2 s .c o m*/ return manager.getScanResults(); } }