取WiFi MAC地址

1、修改AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      ...>
下增加:
   <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

否则会因缺少权限而取不到MAC信息

 

2、取MAC代码片断


   WifiManager wifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
   WifiInfo wifiInfo = wifiManager.getConnectionInfo();
   String macAddress = (wifiInfo == null) ? "Empty" : wifiInfo.getMacAddress();

你可能感兴趣的:(xml,android,Access)