2011-05-21 65 views

回答

7

使用WifiManager

WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE); 
    if (wifiManager != null) { 
     WifiInfo info = wifiManager.getConnectionInfo(); 
     if (info != null) { 
      String ssid = info.getSSID(); 
      ... 
    }   
} 

然後,您需要爲您的清單添加一個權限。

<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />