如何获得版本的Android M preVIEW缺少的无线MAC地址? [英] How to get the missing Wifi MAC Address on Android M Preview?
问题描述
Android开发寻求获得在Android M上的无线MAC地址可能经历的地方标准Android OS API获取MAC地址返回一个错误的MAC地址(02:00:00:00:00:00)的问题,而不是真正的价值。
Android developers looking to get the Wifi MAC Address on Android M may have experienced an issue where the standard Android OS API to get the MAC Address returns a fake MAC Address (02:00:00:00:00:00) instead of the real value.
正常的方式来获得无线MAC地址如下:
The normal way to get the Wifi MAC address is below:
final WifiManager wifiManager = (WifiManager) getApplication().getApplicationContext().getSystemService(Context.WIFI_SERVICE);
final String wifiMACaddress = wifiManager.getConnectionInfo().getMacAddress();
我希望这能帮助一些开发商虽然谷歌仍在调查该MAC地址的API的问题!感谢您的阅读。
I hope this can help out some developers while Google is still investigating the MAC Address API issue! Thanks for reading.
推荐答案
解决!
MAC地址仍然可以从路径抓起:
The MAC Address can still be grabbed from the path:
"/sys/class/net/" + networkInterfaceName + "/address";
简单地做一个文件的读取,或该文件的猫会显示无线MAC地址。
Simply doing a file read, or a cat of that file will show the Wifi MAC Address.
网络接口名称通常是沿着为wlan0或eth1的
Network interface names are usually along the lines of "wlan0" or "eth1"
这篇关于如何获得版本的Android M preVIEW缺少的无线MAC地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!