startLeScan replacement to current api

前端 未结 5 572
北海茫月
北海茫月 2020-12-14 01:18

Goal is to read the values of a bluetooth LE heart rate monitor.

Using google\'s sample, I get

private void scanLeDevice(final boolean enable) {
             


        
5条回答
  •  别那么骄傲
    2020-12-14 02:04

    Use BluetoothAdapter.getBluetoothLeScanner() to get an instance of BluetoothLeScanner.

    Then, you can start or stop a scan with the startScan or stopScan methods, much like the deprecated version.

    Difference is you can pass scanfilters and settings. The ScanCallback has more info about found devices. Filters allow you to filter scanresults based on name, macaddress, service UUIDs etc. Scan settings allow you to control scanning power.

提交回复
热议问题