android 蓝牙 connection refused,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 {

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?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值