我正在尝试通过蓝牙从android设备向hololens发送简单的字符串。
我已经完成了此操作,但是android设备在调用startAdvertising();
BluetoothAdapter mBluetoothAdapter;
BluetoothLeAdvertiser mBLEAdvertiser;
private void startAdvertising(int manufactureId, byte[] manufactureData) throws InterruptedException {
if (mBLEAdvertiser == null) return;
AdvertiseSettings settings = new AdvertiseSettings.Builder()
.setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_BALANCED)
.setConnectable(false)
.setTimeout(0)
.setTxPowerLevel(AdvertiseSettings.ADVERTISE_TX_POWER_MEDIUM)
.build();
AdvertiseData data = new AdvertiseData.Builder()
.addManufacturerData(manufactureId, manufactureData)
.build();
mBLEAdvertiser.startAdvertising(settings, data, mAdvertiseCallback);
答案 0 :(得分:0)
当AdvertiseSettings.Builder#setTimeout()将广告时间的值设置为0时,该时间限制将被禁用,除非调用BluetoothLeAdvertiser#stopAdvertising(),否则广告将一直有效。