如何为Android设备使用本地脚本获取 mac地址?
我尝试在此问题Get mac address and ip in Nativescript
下获取mac我也尝试过:
let mac = java.net.NetworkInterface.getHardwareAddress();
我得到了错误
TypeError: test.getHardwareAddress is not a function
但是,如果我在日志上打印console.log(java.net.NetworkInterface)
,我们将看到getHardwareAddress
谢谢:)
答案 0 :(得分:1)
Manoj's answer为我工作,但自Android 6.0起:
为了向用户提供更大的数据保护,从此版本开始,Android删除了使用Wi-Fi和Bluetooth API对应用的设备本地硬件标识符的编程访问。 WifiInfo.getMacAddress()和BluetoothAdapter.getAddress()方法现在返回常数值02:00:00:00:00:00。