1. 程式人生 > >Android 獲取WIFI 名稱

Android 獲取WIFI 名稱

 獲取WiFi 名稱方法:

WifiManager wifiMgr = (WifiManager) activity.getSystemService(Context.WIFI_SERVICE);

int wifiState = wifiMgr.getWifiState();     
WifiInfo info = wifiMgr.getConnectionInfo();
String wifiId = info != null ? info.getSSID() : null;

去除WiFI名稱兩邊“號:

String name = wifiInfo.getSSID().replace("\"", "");