如何获得在Android上的WIFI接口的MAC地址? [英] How to get MAC address of the WIFI interface in android?

查看:339
本文介绍了如何获得在Android上的WIFI接口的MAC地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用下面的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.

这篇关于如何获得在Android上的WIFI接口的MAC地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆