请问Android设备模拟器有一个MAC地址?模拟器、有一个、地址、设备

2023-09-08 00:10:52 作者:柳桥无复水

我写了下面code,以获得MAC地址:

I wrote the following code to get the MAC address:

WifiManager wimanager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
String address = wimanager.getConnectionInfo().getMacAddress();
Log.d("TOKEN", address);

这完美的作品我的手机上,但在Android模拟器则返回null。这是因为Android模拟器不具有MAC地址?

This works perfectly on my phone, but in the Android emulator it returns null. Is this because the Android emulator doesn't have a MAC address?

推荐答案

这是相同的,当您试图在模拟器上得到的东西,蓝牙的保持的。没有MacAdress,应该返回null。尝试在真实设备上,它会正常工作。在code是正确的。

It's the same as when you try getting a hold of the bluetooth stuff on the emulator. There is no MacAdress and should return null. Try on a real device and it will work. The code is correct.