2

So I faced a problem to get the local Bluetooth address. I try it in 2 phones, one is running Stock Marshmallow and the other is running CM12 Lollipop. I use BluetoothChat sample from Google and add this line

Log.d(TAG, "Local Address: " + mAdapter.getAddress());

In CM12 device it does return the right local MAC Address. While in Stock Marshmallow device, it return this

00:02:00:00:00:00

I use the same source running on those phones and all permission has been granted. But why in Stock Marshmallow does not return the real MAC Address?

Update: Beside those problem. The real MAC Address is sometimes changes and then revert back to the old one. Is it normal that local MAC Address changes?

saggaf.arsyad
  • 801
  • 1
  • 7
  • 11

1 Answers1

2

BluetoothAdapter.getAddress() is intentionally broken since Android M (same with the wifi MAC address). see https://developer.android.com/about/versions/marshmallow/android-6.0-changes.html#behavior-hardware-id This is an obvious violation of the API but intended and will not change.

see also https://code.google.com/p/android-developer-preview/issues/detail?id=2427

EDIT: see my answer here https://stackoverflow.com/a/34016529/1876573

Community
  • 1
  • 1
blobbie
  • 1,279
  • 1
  • 10
  • 8