4

My Unity app was required to get Bluetooth names to distinguish different phones in the same local network. Here is the code that I used to get Bluetooth name:

AndroidJavaClass blueToothAdapter = new AndroidJavaClass("android.bluetooth.BluetoothAdapter");
AndroidJavaObject myPhone = blueToothAdapter.CallStatic<AndroidJavaObject>("getDefaultAdapter");
return myPhone.Call<string>("getName");

Basically, it gets the default bluetooth adapter and then gets its name. It worked for a long time when the tested phones were using Android 6 or 7. But then we bought some new phones which were using Android 11, and they started to return "QCOM-BTD" instead of their Bluetooth names. My question is, is getName() outdated? Or is it the problem of getDefaultAdapter() in new Android version? How can I change the code so it can get the Bluetooth names in new phones?

Sunny Leung
  • 103
  • 4
  • 15
  • Is it possible that that is the default name of the bluetooth chip that hasn't been changed in the settings, because of which it falls back to "QCOM-BTD"? Have you tried changing it and seeing if you get the updated name as a result instead of the default name? – Tom Doodler May 25 '21 at 13:38
  • This is might be a user privacy feature, preventing ad frameworks from fingerprinting and tracking individual users. I had the same issue with getAddress() also returning a generic value. Or maybe BluetoothManger.getAdapter() does work for you. – JeanLuc May 25 '21 at 17:57
  • 1
    @TomDoodler I couldn't see "QCOM-BTD" anywhere inside the phone. I changed the name in the Bluetooth settings and it was still "QCOM-BTD". Is there even a more hidden name that I could change? – Sunny Leung May 26 '21 at 02:13
  • @JeanLuc I could give it a try later. – Sunny Leung May 26 '21 at 02:15

0 Answers0