BluetoothDevice始终在getName()上返回null [英] BluetoothDevice always returns null on getName()

查看:872
本文介绍了BluetoothDevice始终在getName()上返回null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Android 4.4、5和6中始终遇到此问题。

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

我正在执行BLE蓝牙设备扫描,然后可以访问它们的地址(getAddress())和其他数据。但是,如果我调用device.getName(),它每次都会返回null。

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.

该文档没有帮助,它只说如果有问题则返回null: https://developer.android.com/reference/android/ bluetooth / BluetoothDevice.html#getName()

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()返回null

可以使用的设备bluetoothdevice.getname()返回null

PS:我使用的是非Android API级别21+中已弃用的方法,因此与该问题无关。

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?

推荐答案

可能是您的BLE设备没有广播名称。广播有效载荷限制为31个字节,某些制造商省略了名称以节省空间。

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.

这篇关于BluetoothDevice始终在getName()上返回null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆