且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

蓝牙连接失败“java.io.IOException:读取失败,套接字可能关闭或超时,读取 ret:-1"

更新时间:2022-05-16 07:56:21

BluetoothConnector.java的构造函数中,传入了一个uuidCandidates列表.

In the constructor of BluetoothConnector.java, a list of uuidCandidates is passed.

public BluetoothConnector(BluetoothDevice device, boolean secure, BluetoothAdapter adapter,
                              List<UUID> uuidCandidates) 
          {
        this.device = device;
        this.secure = secure;
        this.adapter = adapter;
        this.uuidCandidates = uuidCandidates;

        if (this.uuidCandidates == null || this.uuidCandidates.isEmpty()) {
            this.uuidCandidates = new ArrayList<UUID>();
            this.uuidCandidates.add(UUID.fromString("fa87c0d0-afac-11de-8a39-0800200c9a66"));
        }
    }

你把它传给空了吗?

如果是,则尝试为您要连接的蓝牙设备调用 device.fetchUuidsWithSdp() 并在接收器中接收 BluetoothDevice.ACTION_UUID 意图.因为这将获取设备支持的 uuid 列表.

If yes,then try calling device.fetchUuidsWithSdp() for the Bluetooth device you want to connect and receive BluetoothDevice.ACTION_UUID intent in your receiver.As this will fetch a list of uuids supported for the device.