Bluetooth Connection failed “java.io.IOException: read failed, socket might closed or timeout, read ret: -1”

后端 未结 3 1641
半阙折子戏
半阙折子戏 2020-12-01 16:32

I am trying to connect devices through my app installed in Nexus 5.I want to make an app like rainbow contacts in android. In my app I aim to connect to another device throu

3条回答
  •  悲&欢浪女
    2020-12-01 17:14

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

    public BluetoothConnector(BluetoothDevice device, boolean secure, BluetoothAdapter adapter,
                                  List uuidCandidates) 
              {
            this.device = device;
            this.secure = secure;
            this.adapter = adapter;
            this.uuidCandidates = uuidCandidates;
    
            if (this.uuidCandidates == null || this.uuidCandidates.isEmpty()) {
                this.uuidCandidates = new ArrayList();
                this.uuidCandidates.add(UUID.fromString("fa87c0d0-afac-11de-8a39-0800200c9a66"));
            }
        }
    

    Have you passed it null?

    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.

提交回复
热议问题