我正在使用ble服务连接外设,但连接有奇怪的问题,有些时候以下方法没有连接设备,有时它完美地工作,比例为10:1
private void scanLeDevice(final boolean enable) {
if (enable) {
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
mBluetoothAdapter.stopLeScan(mLeScanCallback);
connectToPeripheral();
}
}, 15000);
mBluetoothAdapter.startLeScan(mLeScanCallback);
} else {
mBluetoothAdapter.stopLeScan(mLeScanCallback);
}
}
Method connectToPeripheral is for connection and data receiving,I stuck with problem since long time don't have any idea why this happening if i kill the app than connect still have same problem.is it problem of Advertising delay?