2

i'm trying to get bluetooth mac address in this way:

mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();

String address = mBluetoothAdapter.getAddress();

But it always returns:

02:00:00:00:00:00

Why? Is it a kind of security policy?

Thanks.

Giacomo

Ivam
  • 379
  • 3
  • 12
Giacomo
  • 21
  • 1
  • Have a look at [this](https://duckduckgo.com/?q=android+bluetooth+mac+address&ia=qa) – Ivam Jul 05 '18 at 20:28

1 Answers1

0

Maybe you should check out this answer.

Snippet from answer:

 private String getBluetoothMac(final Context context) {

    String result = null;
    if (context.checkCallingOrSelfPermission(Manifest.permission.BLUETOOTH)
            == PackageManager.PERMISSION_GRANTED) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            // Hardware ID are restricted in Android 6+
            // https://developer.android.com/about/versions/marshmallow/android-6.0-changes.html#behavior-hardware-id
            // Getting bluetooth mac via reflection for devices with Android 6+
            result = android.provider.Settings.Secure.getString(context.getContentResolver(),
                    "bluetooth_address");
        } else {
            BluetoothAdapter bta = BluetoothAdapter.getDefaultAdapter();
            result = bta != null ? bta.getAddress() : "";
        }
    }
    return result;
}