Android O蓝牙扫描限制问题达成了问题

问题描述 投票:0回答:1

尝试在Android O中实现定期蓝牙扫描。

代码每隔15分钟进行一次扫描,最终得到以下错误;

09-05 10:33:26.387 I:[INFO:gatt_api.cc(1004)] GATT_Register 09-05 10:33:26.387 E:[ERROR:gatt_api.cc(1032)]无法注册GATT客户端,MAX客户端达到:32 09-05 10:33:26.387 E:注册GATT堆栈失败。

代码如下;

ScanSettings settings = (new ScanSettings.Builder()
                .setScanMode(ScanSettings.SCAN_MODE_OPPORTUNISTIC)).build();

BluetoothManager bluetoothManager =
                (BluetoothManager) context.getSystemService(Context.BLUETOOTH_SERVICE);
BluetoothAdapter bluetoothAdapter = bluetoothManager.getAdapter();

Intent intent = new Intent(context, ScannerBroadcastReceiver.class);
intent.putExtra("o-scan", true);
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
bluetoothAdapter.getBluetoothLeScanner().startScan(BleUtils.buildScanFilters(), settings, pendingIntent));

任何帮助,将不胜感激。

android beacon altbeacon
1个回答
0
投票

此症状通常表明蓝牙堆栈已进入状态不佳,需要蓝牙(或电话)循环才能恢复。每当你看到这个,首先尝试关闭蓝牙,等待30秒,然后重新打开,看看它是否恢复。

如果您发现蓝牙电源循环有帮助,您可以使用该库的蓝牙军医类来自动执行此恢复。

如果重新启动蓝牙或整个设备确实解决了问题,则可能没有其他解决方案。在它出现的时候寻找模式仍然是值得的,这样你至少知道问题有多严重。它是否与被检测的许多信标相关?启动手机后显示需要多长时间?知道这些问题的答案至少会让你知道你正在处理的问题有多糟糕。

© www.soinside.com 2019 - 2024. All rights reserved.