Android 获取手机Mac地址,手机名称

/**
* 获取手机mac地址<br/>
* 错误返回12个0
*/
public static String getMacAddress(Context context) {
// 获取mac地址:
String macAddress = "000000000000";
try {
WifiManager wifiMgr = (WifiManager) context
.getSystemService(Context.WIFI_SERVICE);
WifiInfo info = (null == wifiMgr ? null : wifiMgr
.getConnectionInfo());
if (null != info) {
if (!TextUtils.isEmpty(info.getMacAddress()))
macAddress = info.getMacAddress().replace(":", "");
else
return macAddress;
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
return macAddress;
}
return macAddress;
}

获取手机名称

android.os.Build.MANUFACTURER
上一篇:0.9.0.RELEASE版本的spring cloud alibaba sentinel限流、降级处理实例


下一篇:Docker使用札记 - 常用命令