admin管理员组

文章数量:1548470

一、Android  获取本机Mac 地址方法:java

须要在AndroidManifest.xml文件中添加权限:android

shell

Java代码服务器

public String getLocalMacAddress() {

WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);

WifiInfo info = wifi.getConnectionInfo();

return info.getMacAddress();

}

二、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();

}

本文标签: 模拟器通讯地址Socketandroid