Custom list adapter and ListView

For the UI purposes, it is good to have a custom list adapter that shows the name and address of the scanned Bluetooth device in the list. For this purpose, we created a custom adapter class BluetoothLeListAdapter extending the BaseAdapter. The constructor of the adapter creates an empty ArrayList of BluetoothDevice class which will later be used to hold all the scanned devices.

public BluetoothLeListAdapter(Activity baseActivity) {     super();     mLeDevices = new ArrayList<BluetoothDevice>();     mInflator = (LayoutInflater) baseActivity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); }

In the addDevice method, mLeDevices are updated with newly scanned devices. This task will be achieved by:

 public void addDevice(BluetoothDevice ...

Get Building Bluetooth Low Energy Systems now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.