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??
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.
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.
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.
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".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With