1

我已经编写了以下代码,以根据链接中提供的解决方案连续扫描蓝牙设备。根据该解决方案,我的设备应连续扫描/搜索范围内的蓝牙设备,但在我的情况下,扫描仅发生约 64 秒。

我已经在两台设备上测试了这段代码,一台使用 Android V2.2,另一台使用 V2.3,这两款设备仅扫描约 64 秒。

如何让我的设备连续扫描?

    public void onReceive(Context context, Intent intent) {

        String action = intent.getAction();
        if(BluetoothDevice.ACTION_FOUND.equals(action)){

          //Do Something

        }else if(BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)){
            btAdapter.startDiscovery();
        }
    }
4

0 回答 0