如何获得在Android上的WIFI接口的MAC地址?如何获得、接口、地址、WIFI

2023-09-05 11:26:33 作者:余生颓废

我使用下面的code:

I am using the following code:

WifiManager wifiMgr = (WifiManager) app.getSystemService(Context.WIFI_SERVICE);
return wifiMgr.getConnectionInfo().getMacAddress();

但问题是,在WIFI必须启用的设备,以便给我读它的地址。 我怎样才能读到这个WIFI的MAC即使WIFI处于关闭状态?

Problem is, the WIFI must be ENABLED in the device in order for me to read its address. How can I still read the MAC of the WIFI even if the WIFI is off?

推荐答案

您不能。根据设备的不同,如果WiFi适配器被禁用的话,就可能实际上被电子关闭,所以你不能读取任何信息。

You can't. Depending on the device, if the wifi adapter is disabled then it may actually be electronically switched off, so you can't read any info from it.

从 Android开发者博客:

MAC地址

这也许可以从中检索MAC地址   设备的WiFi或蓝牙硬件。我们不建议使用此作为   的唯一标识符。首先,不是所有的设备都有无线网络。 同时,   如果在WiFi未接通时,硬件可能不报告在Mac   地址。

It may be possible to retrieve a Mac address from a device’s WiFi or Bluetooth hardware. We do not recommend using this as a unique identifier. To start with, not all devices have WiFi. Also, if the WiFi is not turned on, the hardware may not report the Mac address.