问题
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