BluetoothAdapter getAddress() return 02:00:00:00:00:00

我怕爱的太早我们不能终老 提交于 2020-06-01 04:04:30

问题


I try to return the Bluetooth mac address of my device but this is not working and return this address : 02:00:00:00:00:00 .

-I'm using API Level 28
-I can get my Bluetooth mac address in my android system settings but not programmatically in my app.
-I can get the mac address of this device programmatically from other devices.

What I understand is that access to address mac is only for system applications ,but if It's true why other devices get my mac address and not me !

BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
test.setText(adapter.getAdress());

I try many permissions but still the same problem !

<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.BLUETOOTH_PRIVILEGED" />
<uses-permission android:name="android.permission.LOCAL_MAC_ADDRESS" />
<uses-permission android:name="android.permission.INTERNET" />

回答1:


Since Android 6, Marshmallow apps do not have access anymore to the bluetooth hardware MAC address. This change was made because the address was abused by many apps to identify and track smartphones. To avoid that existing apps are broken the getter method still exists but it returns a dummy address. For details see the corresponding note within Android's official release notes here

But what about visibility of the MAC address to other devices?

  • Bluetooth Low Energy (LE) does not use the hardware MAC address for communication. It uses a randomized variant of it (see here for details). Since Bluetooth LE does not stop scanning for nearby devices in background even when the user explicitly disables Bluetooth this feature is considerable ;-)

  • Bluetooth classic does not randomize the MAC address. But in constrast to Bluetooth LE the user can at least easily and fully disable Bluetooth.



来源:https://stackoverflow.com/questions/62067259/bluetoothadapter-getaddress-return-020000000000

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!