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?