Wun
Wun

Reputation: 6381

How to use LeDeviceListAdapter when trying to find BLE-devices?

I'm working on an application in Android,and I follow the Codesuggestion from the Android developers page

When I type the code:

private LeDeviceListAdapter mLeDeviceListAdapter;

It has error message:

LeDeviceListAdapter cannot be resolved to a type

What do I have to fix this error??

Upvotes: 19

Views: 27140

Answers (2)

Hunter S
Hunter S

Reputation: 1311

The LeDeviceListAdapter class is not built into the Android APIs; you have to create it yourself. I found the class -- the one that the Android tutorials intended for you to use -- at this link:

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

Just search the page for "LeDeviceListAdapter".

Upvotes: 11

reTs
reTs

Reputation: 1829

The code is actually only extracts of the BTLE sample project inside the Android SDK. You should read the article with the sample project together.

The path of the sample project is /sdk/samples/android-18/legacy/BluetoothLeGatt

If you are only interested in what LeDeviceListAdapter is , here is the code in pastebin

Also I recommend you to read about how AdapterView (ListView's parent) and Adapter works. Nothing to do with the actual BLE work, but you will suffer in understanding the sample code if you don't understand what's happening.

Upvotes: 14

Related Questions