【发布时间】:2011-12-26 01:14:25
【问题描述】:
我应该在 readLine 上为蓝牙输入流插入超时。
BluetoothDevice device = BluetoothAdapter.getDefaultAdapter()
.getRemoteDevice("00:00:00:00:00:00");
sock = device.createInsecureRfcommSocketToServiceRecord(UUID
.fromString(insecureUUID));
sock.connect();
in = new BufferedReader(new InputStreamReader(sock.getInputStream()));
String line = in.readLine(); //if no answer from device..i'll wait here forever
do { [...]
} while ((line = in.readLine()) != null);
连接工作正常,但我有一个蓝牙串行转换器链接到另一台设备。如果第二个被关闭,我将在 readLine 上永远等待。我有机会抛出异常或超时吗? 谢谢!!
【问题讨论】:
标签: android sockets bluetooth timeout