1、btSocket = btDev
.createRfcommSocketToServiceRecord(uuid);
btSocket.connect();
2、 btSocket =(BluetoothSocket) btDev.getClass().getMethod("createRfcommSocket", new Class[] {int.class}).invoke(btDev,1);
btSocket.connect();
第一个连接方式都试过了都报
java.IOException:read failed,socket might closed or timeout.read ret:-1
第二个解决了蓝牙连接问题,可以实现防丢功能,不需要传数据,不需要使用到uuid
tmp = device.createRfcommSocketToServiceRecord(UUID.fromString(UUID_STR));
tmp =(BluetoothSocket) device.getClass().getMethod("createRfcommSocket", new Class[] {int.class}).invoke(device,1);