Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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??

like image 959
Wun Avatar asked Sep 24 '13 10:09

Wun


People also ask

How do you detect BLE devices?

To find BLE devices, you use the startScan() method. This method takes a ScanCallback as a parameter. You must implement this callback, because that is how scan results are returned.

How do I connect my Android to BLE?

Use of the Bluetooth LE APIs requires you to declare several permissions in your manifest file. Once your app has permission to use Bluetooth, your app needs to access the BluetoothAdapter and determine if Bluetooth is available on the device. If Bluetooth is available, the device will scan for nearby BLE devices.


2 Answers

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.

like image 178
reTs Avatar answered Oct 11 '22 23:10

reTs


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".

like image 39
Hunter S Avatar answered Oct 12 '22 01:10

Hunter S