I have a problem when I call sock.connect (), it just hangs endlessly. There is no exception and no timeout.
try { Method m = dev.getClass().getMethod("createRfcommSocket", new Class[] {int.class}); sock = (BluetoothSocket) m.invoke(dev, 1); sock.connect(); Thread.sleep(100); in = sock.getInputStream(); out = sock.getOutputStream(); } catch(ConnectTimeoutException ex) { return false; } catch(IOException ex) { return false; } catch(Exception ex) { return false; }
The reason is that another application is already using a Bluetooth device. I try to make my connection fail and at least throw an exception or something to tell me that the device is already in use by another application.
Any other suggestions on this?
Thanks.
source share