Thursday, April 19, 2012

Connection refused on bluetooth socket.connect() - android

First, I know this issue has been up before but none of the sugested solutions i found solves my problem...

After pairing device with

Method m = device.getClass().getMethod("createRfcommSocket", new Class[] {int.class});
tmp = (BluetoothSocket) m.invoke(device, 1);

I try to connect using

boolean connected = false;
String cause = "";
for(int i=0; i<3; i++){
try {
} catch (IOException e) {
Log.e("btact","fail"+i+" - "+e.getMessage());
cause = e.getMessage();
connected = true;

try {
} catch (IOException e2) {
Log.e(TAG, "unable to close() " + mSocketType +
" socket during connection failure", e2);

Log.e("----btact----", cause);

This gives me
fail0 - Connection refused
fail1 - File descriptor in bad state
fail2 - File descriptor in bad state
File descriptor in bad state

Whay may cause this problem and how do I solve it?

No comments:

Post a Comment