哪种类型关于如何使用android蓝牙套接字连接更好

时间:2014-12-12 01:59:34

标签: android sockets bluetooth connection

输入一个:

Method m = btDevice.getClass().getMethod("createRfcommSocket", new Class[] { int.class });

btSocket = (BluetoothSocket) m.invoke(btDevice, 1);

btSocket.connect();

键入二:

private final UUID SPP_UUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
btSocket = btDevice.createInsecureRfcommSocketToServiceRecord(SPP_UUID);
btSocket.connect();

1 个答案:

答案 0 :(得分:0)

显然第二种解决方案更好,因为它在内部实现了更好的错误处理。

来源: https://stackoverflow.com/a/18582044/3250699