在获取页面调用下面方法即可,
public static String getMacAddressFromIp(Context context) {
String mac_s= "";
StringBuilder buf = new StringBuilder();
try {
byte[] mac;
NetworkInterface ne=NetworkInterface.getByInetAddress(InetAddress.getByName(getIpAddress(context)));
mac = ne.getHardwareAddress();
for (byte b : mac) {
buf.append(String.format("%02X:", b));
}
if (buf.length() > 0) {
buf.deleteCharAt(buf.length() - 1);
}
mac_s = buf.toString();
} catch (Exception e) {
e.printStackTrace();
}
return mac_s;
}
也尝试过其他方法,但是都不怎么有效。