Sub Activity_Create(FirstTime As Boolean)
Dim jo As JavaObject = Me
Log(jo.RunMethod("getWifiMacAddress", Null))
End Sub
#if JAVA
import java.net.NetworkInterface;
import java.util.Collections;
import java.util.List;
public static String getWifiMacAddress() {
try {
String interfaceName = "wlan0";
List<NetworkInterface> interfaces = Collections.list(NetworkInterface.getNetworkInterfaces());
for (NetworkInterface intf : interfaces) {
if (!intf.getName().equalsIgnoreCase(interfaceName)){
continue;
}
byte[] mac = intf.getHardwareAddress();
if (mac==null){
return "";
}
StringBuilder buf = new StringBuilder();
for (byte aMac : mac) {
buf.append(String.format("%02X:", aMac));
}
if (buf.length()>0) {
buf.deleteCharAt(buf.length() - 1);
}
return buf.toString();
}
} catch (Exception ex) {
ex.printStackTrace();
}
return "";
}
#end if