linux mac地址文件夹,android4.4.2系统的mac地址文件在哪个文件里面
android 是Linux內核,linux中mac地址是保存在/etc/init.d/networ 文件中的
但是在android中mac地址是直接寫在硬件中的,需要通過API 才能獲取
1、Android 獲取本機Mac 地址方法:
需要在AndroidManifest.xml文件中添加權限:
public String getLocalMacAddress() {
WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
WifiInfo info = wifi.getConnectionInfo();
return info.getMacAddress();
}
2、Android 獲取本機IP地址方法:
public String getLocalIpAddress() {
try {
for (Enumeration en = NetworkInterface
.getNetworkInterfaces(); en.hasMoreElements();) {
NetworkInterface intf = en.nextElement();
for (Enumeration enumIpAddr = intf
.getInetAddresses(); enumIpAddr.hasMoreElements();) {
InetAddress inetAddress = enumIpAddr.nextElement();
if (!inetAddress.isLoopbackAddress()) {
return inetAddress.getHostAddress().toString();
}
}
}
} catch (SocketException ex) {
Log.e("WifiPreference IpAddress", ex.toString());
}
return null;
}
取消
評論
總結
以上是生活随笔為你收集整理的linux mac地址文件夹,android4.4.2系统的mac地址文件在哪个文件里面的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 三星平板电脑官网商城(三星平板电脑应用商
- 下一篇: linux-macbook内核,技术|用