Android BLE ---- ADVERTISE_FAILED_DATA_TOO_LARGE

在写Android BLE Server端的时候,发现start advertise的时候,报出ADVERTISE_FAILED_DATA_TOO_LARGE的错误:

 AdvertiseData data = new AdvertiseData.Builder()
                .setIncludeDeviceName(true)
                .addServiceUuid(new ParcelUuid(DeviceProfile.SERVICE_UUID))
                .build();
mBluetoothLeAdvertiser.startAdvertising(settings, data, mAdvertiseCallback);

这种错误表示你填充的数据过大,经常是因为这段代码

.setIncludeDeviceName(true)

可以有两种处理方法:

  • 在上面方法中传入false
  • 到系统的蓝牙设置里面,将你的蓝牙的名字改短

你可能感兴趣的:(android蓝牙)