Search code examples
androidbluetoothbluetooth-lowenergyandroid-bluetoothandroid-ble

BluetoothDevice always returns null on getName()


I'm facing this issue consistently in Android 4.4, 5 and 6.

I'm performing a BLE Bluetooth devices scan and after it I can access their address (getAddress()), and other data. But if I call device.getName() it returns null EVERY TIME.

This documentation is not helpful, it only says that returns null if "there was a problem" : https://developer.android.com/reference/android/bluetooth/BluetoothDevice.html#getName()

Other posts that I visited unsuccessfully :

https://code.google.com/p/android/issues/detail?id=34411

android BluetoothDevice.getName() return null

ble device bluetoothdevice.getname() returns null

PS: I'm using non-deprecated methods in Android API level 21+, so that's not related to the issue.

Any idea about what could be going wrong here?


Solution

  • It could be that your BLE device isn't broadcasting a name. The broadcast payload is limited to 31 bytes and some manufacturers omit a name to save room.