需要实现一个过滤条件为DeviceName的功能。
1.蓝牙扫描的时候有两种方法。
1.1 mBluetoothAdapter.startLeScan(mLeScanCallback);(这个方法已经过时)
BluetoothManager bm = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
BluetoothAdapter mBluetoothAdapter = bm.getAdapter();
mBluetoothAdapter.startLeScan(mLeScanCallback);
1.2
BluetoothManager bm = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
BluetoothAdapter mBluetoothAdapter = bm.getAdapter();
BluetoothLeScanner bluetoothLeScanner = mBluetoothAdapter.getBluetoothLeScanner();
BluetoothLeScanner有两个方法:
方法1:
@RequiresPermission(Manifest.permission.BLUETOOTH_ADMIN)
public void startScan(final ScanCallback callback) {