*/
public static String getMac() {
String macSerial = null;
String str = “”;
try {
Process pp = Runtime.getRuntime().exec("cat /sys/class/net/wlan0/address ");
InputStreamReader ir = new InputStreamReader(pp.getInputStream());
LineNumberReader input = new LineNumberReader(ir);
for (; null != str; ) {
str = input.readLine();
if (str != null) {
macSerial = str.trim();// 去空格
break;
}
}
} catch (IOException ex) {
// 赋予默认值
ex.printStackTrace();
}
return macSerial;
}
通过读取/sys/class/net/wlan0/address文件获取
/**
-
Android 6.0(包括) - Android 7.0(不包括)
-
@return
*/
private static String getMacAddress() {
String WifiAddress = “02:00:00: