安卓获取手机mac值方法:
注:方法一(adb shell命令在安卓7.0及以后不能用)
方法一:
/**
* 这是使用adb shell命令来获取mac地址的方式
* @return
*/
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) {