For the scanning process, following objects should be prepared in order:
BluetoothManager mBluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE); BluetoothAdapter mBluetoothAdapter = mBluetoothManager.getAdapter();
getSystemService() method brings back the Bluetooth Service Manager, if called with Context.BLUETOOTH_SERVICE. This manager can then be used to get the adapter which is the core of the Bluetooth operation. As mentioned in the code, mBluetoothAdapter can be acquired by calling getAdapter() on the BluetoothManager object. This bluetooth adapter will now be used to get the BluetoothLeScanner object:
mBluetoothLeScanner = mBluetoothAdapter.getBluetoothLeScanner();
It is a good ...