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 {
mmSocket.connect();
} catch (IOException e) {
Log.e("btact","fail"+i+" - "+e.getMessage());
cause = e.getMessage();
continue;
}
connected = true;
}
if(!connected){
try {
mmSocket.close();
} catch (IOException e2) {
Log.e(TAG, "unable to close() " + mSocketType +
" socket during connection failure", e2);
}
Log.e("----btact----", cause);
connectionFailed();
return;
}
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