在Android机顶盒上 怎样获取有线网卡MAC地址
展开全部
先关闭wifi,在运行以下java代码:
获取当前连接网络的网卡的mac地址
private static String parseByte(byte b) {
String s = "00" + Integer.toHexString(b)+":";
return s.substring(s.length() - 3);
}
/**
* 获取当前系统连接网络的网卡的mac地址
* @return
*/
@SuppressLint("NewApi")
public static final String getMac() {
byte[] mac = null;
StringBuffer sb = new StringBuffer();
try {
Enumeration<NetworkInterface> netInterfaces = NetworkInterface.getNetworkInterfaces();
while (netInterfaces.hasMoreElements()) {
NetworkInterface ni = netInterfaces.nextElement();
Enumeration<InetAddress> address = ni.getInetAddresses();
获取当前连接网络的网卡的mac地址
private static String parseByte(byte b) {
String s = "00" + Integer.toHexString(b)+":";
return s.substring(s.length() - 3);
}
/**
* 获取当前系统连接网络的网卡的mac地址
* @return
*/
@SuppressLint("NewApi")
public static final String getMac() {
byte[] mac = null;
StringBuffer sb = new StringBuffer();
try {
Enumeration<NetworkInterface> netInterfaces = NetworkInterface.getNetworkInterfaces();
while (netInterfaces.hasMoreElements()) {
NetworkInterface ni = netInterfaces.nextElement();
Enumeration<InetAddress> address = ni.getInetAddresses();
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询