在底层获取安卓wifi的mac地址

public static String  getLocalMac() {
    String mac=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)
            {
                mac = str.trim();// 去空格
                break;
            }
        }
    } catch (IOException ex) {
        // 赋予默认值
        ex.printStackTrace();
    }
    return mac;
}

你可能感兴趣的:(在底层获取安卓wifi的mac地址)