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