问题 如何在尝试查找BLE设备时使用LeDeviceListAdapter?


我正在使用Android中的应用程序,我遵循Android的Codesuggestion 开发者页面

当我输入代码时:

private LeDeviceListAdapter mLeDeviceListAdapter;

它有错误消息:

LeDeviceListAdapter无法解析为某种类型

我该怎么办才能解决这个错误?


6366
2017-09-24 10:02


起源



答案:


该代码实际上只是Android SDK中BTLE示例项目的摘录。您应该一起阅读带有示例项目的文章。

示例项目的路径是/ sdk / samples / android-18 / legacy / BluetoothLeGatt

如果您只对LeDeviceListAdapter感兴趣,请参阅以下代码 引擎收录

另外,我建议您阅读AdapterView(ListView的父级)和适配器的工作原理。与实际的BLE工作无关,但如果您不了解正在发生的事情,您将会理解示例代码。


8
2017-09-24 10:27



它真的很棒(呃......我的意思是在最基本的水平上有帮助),实际上与用户分享......令人沮丧的浪费时间来自己解决这个问题,特别是因为在sdk中等级19没有BLEGatt的示例项目。 - dudewad
对于API 19,BLEGatt样本位于/ sdk / samples / android-10 / connectivity / BluetoothLeGatt下 - Kevin


答案:


该代码实际上只是Android SDK中BTLE示例项目的摘录。您应该一起阅读带有示例项目的文章。

示例项目的路径是/ sdk / samples / android-18 / legacy / BluetoothLeGatt

如果您只对LeDeviceListAdapter感兴趣,请参阅以下代码 引擎收录

另外,我建议您阅读AdapterView(ListView的父级)和适配器的工作原理。与实际的BLE工作无关,但如果您不了解正在发生的事情,您将会理解示例代码。


8
2017-09-24 10:27



它真的很棒(呃......我的意思是在最基本的水平上有帮助),实际上与用户分享......令人沮丧的浪费时间来自己解决这个问题,特别是因为在sdk中等级19没有BLEGatt的示例项目。 - dudewad
对于API 19,BLEGatt样本位于/ sdk / samples / android-10 / connectivity / BluetoothLeGatt下 - Kevin


LeDeviceListAdapter class没有内置到Android API中;你必须自己创造它。我在这个链接上找到了这个类 - 这是Android教程打算让你使用的类:

https://android.googlesource.com/platform/development/+/7167a054a8027f75025c865322fa84791a9b3bd1/samples/BluetoothLeGatt/src/com/example/bluetooth/le/DeviceScanActivity.java

只需在页面中搜索“LeDeviceListAdapter”即可。


4
2017-07-11 21:43