简体   繁体   English

获取的安卓蓝牙MAC为02:00:00:00:00:00

[英]Android bluetooth MAC obtained is 02:00:00:00:00:00

Trying to get the Bluetooth of an android phone with试图获得安卓手机的蓝牙

BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
String bleMAC = bluetoothAdapter.getAddress();

the result of the function is 02:00:00:00:00:00 , i am expecting some thing the lines of 00:04:61:02:AA:FF函数的结果是02:00:00:00:00:00 ,我期待00:04:61:02:AA:FF 的行

Also noticed that wifi mac address are same as Bluetooth mac address.还注意到wifi mac地址与蓝牙mac地址相同。 Can the wifi MAC address be used?可以使用wifi MAC地址吗?

As Per Android 6.0 Changes:根据 Android 6.0 更改:

https://developer.android.com/about/versions/marshmallow/android-6.0-changes.html#behavior-hardware-id https://developer.android.com/about/versions/marshmallow/android-6.0-changes.html#behavior-hardware-id

To provide users with greater data protection, starting in this release, Android removes programmatic access to the device's local hardware identifier for apps using the Wi-Fi and Bluetooth APIs.为了向用户提供更好的数据保护,从本版本开始,Android 删除了使用 Wi-Fi 和蓝牙 API 的应用程序对设备本地硬件标识符的编程访问。 The WifiInfo.getMacAddress() and the BluetoothAdapter.getAddress() methods now return a constant value of 02:00:00:00:00:00. WifiInfo.getMacAddress() 和 BluetoothAdapter.getAddress() 方法现在返回一个常量值 02:00:00:00:00:00。

To access the hardware identifiers of nearby external devices via Bluetooth and Wi-Fi scans, your app must now have the ACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION permissions.要通过蓝牙和 Wi-Fi 扫描访问附近外部设备的硬件标识符,您的应用现在必须具有 ACCESS_FINE_LOCATION 或 ACCESS_COARSE_LOCATION 权限。

According to Android document WifiInfo API , an Android app has to be a system app and get below 2 permissions:根据 Android 文档WifiInfo API ,Android 应用程序必须是系统应用程序并获得以下 2 个权限:

  • android.Manifest.permission.LOCAL_MAC_ADDRESS android.Manifest.permission.LOCAL_MAC_ADDRESS
  • Manifest.permission.ACCESS_FINE_LOCATION Manifest.permission.ACCESS_FINE_LOCATION

I tried on a rooted device of Android 10, it worked well.我在 Android 10 的 root 设备上尝试过,效果很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM