1、获取Mac地址:文章来源地址https://www.toymoban.com/news/detail-638229.html
public static String GetMAC(Context context) { String Mac = ""; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && Build.VERSION.SDK_INT <= Build.VERSION_CODES.N) { Mac = getMacAddress(); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { Mac = getMacFromHardware(); } return Mac; } /** * Android 6.0-Android 7.0 获取mac地址 */ private static String getMacAddress() { 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); while (null != str) { str = input.readLine(); if (str != null) { Mac = str.trim();//去空格 break; }
文章来源:https://www.toymoban.com/news/detail-638229.html
到了这里,关于Android获取mac地址、OA地址和外网IP地址的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!