1

I am currently able to get the Bluetooth adapter mac address on devices with sdk from Marshmallow till Oreo. However, starting Pie, the retrieved mac address is null.

The following method is working only till and including oreo.

<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
    <uses-permission
        android:name="android.permission.LOCAL_MAC_ADDRESS"
        tools:ignore="ProtectedPermissions" />
    <uses-permission android:name="READ_PRIVILEGED_PHONE_STATE" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.BLUETOOTH" />

BluetoothAdapter btAdapter = BluetoothAdapter.getDefaultAdapter();  
String macAddress = Settings.Secure.getString(context.getContentResolver(), "bluetooth_address");
            return macAddress;

I also tried to access BluetoothAdapter.getDefaultAdapter().getAddress() but it returns a fake Mac address like this "02:00:00:00:00"

I only ask the user for runtime permission for fine location. Should I ask for something else? Is there a way to achieve this on Pie and 10?

N.B: I know such app can not be uploaded to Google Play. I just want to implement this for testing purposes on personal devices.

Mena
  • 3,019
  • 1
  • 25
  • 54

0 Answers0