Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Bluetooth local mac address in Marshmallow

Pre Marshmallow my app would obtain it's device MAC address via BluetoothAdapter.getDefaultAdapter().getAddress().

Now with Marshmallow Android is returning 02:00:00:00:00:00.

I saw some link(sorry not sure where now) that said you need to add the additional permission

<uses-permission android:name="android.permission.LOCAL_MAC_ADDRESS"/>  

to be able to get it. However it isn't working for me.

Is there some additional permission needed to get the mac address?

I am not sure it is pertinent here but the manifest also includes

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> 

So is there a way to get the local bluetooth mac address?

like image 453
Eric Avatar asked Oct 27 '15 20:10

Eric


People also ask

How do I find my Bluetooth UUID MAC?

Have a look at About this Mac > System Report... > Hardware > Bluetooth . You'll find there all the information you need about the Bluetooth settings for the machine.

Does Bluetooth have a MAC address?

A Bluetooth address sometimes referred to as a Bluetooth MAC address, is a 48-bit value that uniquely identifies a Bluetooth device. In the Bluetooth specification, it is referred to as BD_ADDR .


2 Answers

zmarties is right but you can still get the mac address via reflection or Settings.Secure:

  String macAddress = android.provider.Settings.Secure.getString(context.getContentResolver(), "bluetooth_address"); 
like image 123
blobbie Avatar answered Oct 03 '22 15:10

blobbie


Access to the mac address has been deliberately removed:

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.

(from Android 6.0 Changes)

like image 33
zmarties Avatar answered Oct 03 '22 13:10

zmarties