gpt4 book ai didi

android - 获取没有Wifi的android设备的MAC地址

转载 作者:IT老高 更新时间:2023-10-28 23:03:39 28 4
gpt4 key购买 nike

如何获取没有 Wifi 接口(interface)的安卓设备(例如安卓模拟器)的网络接口(interface)的 MAC 地址?通过WifiManager获取的WifiInfo返回null

编辑

更清楚地说:我必须与本地网络上的现有网络协议(protocol)(不是我设计的)通信,我必须在注册阶段在有效负载中发送通信接口(interface)的 mac 地址。

最佳答案

我将迈出一大步,假设您需要此 MAC 地址来为设备建立唯一标识符。 Mac 地址不是这样做的方法。

有一篇名为“Identifying App Installations”的 Android 开发者博客文章很好地涵盖了生成唯一 ID 的主题,包括流行的方法和优缺点。这绝对值得一读。与这篇文章非常相关的是以下引用:

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.

您可以使用的选项包括 TelephonyManager.getDeviceId()、android.os.Build.SERIAL 和 Settings.Secure.ANDROID_ID,所有这些都在链接的帖子中进行了更详细的介绍。

关于android - 获取没有Wifi的android设备的MAC地址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6191832/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com