IOException: read failed, socket might closed - Bluetooth on Android 4.3

后端 未结 16 2123
天涯浪人
天涯浪人 2020-11-22 04:08

Currently I am trying to deal with a strange Exception when opening a BluetoothSocket on my Nexus 7 (2012), with Android 4.3 (Build JWR66Y, I guess the second 4.3 update). I

16条回答
  •  鱼传尺愫
    2020-11-22 04:53

    I've had this problem and the solution was to use the special magic GUID.

                val id: UUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB") // Any other GUID doesn't work.
                val device: BluetoothDevice = bta!!.bondedDevices.first { z -> z.name == deviceName }
    
                bts = device.createRfcommSocketToServiceRecord(id) // mPort is -1
                bts?.connect()
                // Start processing thread.
    

    I suspect that these are the UUIDs that work:

    var did: Array = device.uuids
    

    However, I have not tried them all.

提交回复
热议问题