我正在尝试使用pythonbluez通过蓝牙从Android客户端(nexus4)向Python服务器(Linux机器)发送数据。每当客户端向OutputStream写入一些字节时,它就会抛出一个IO异常“断管”。服务器似乎也不接受任何连接,尽管Android客户端在“socket”之后没有抛出任何异常_名称.连接()”
Android客户端:public class MainActivity extends Activity {
private BluetoothSocket ClientSocket;
private BluetoothDevice Client;
private ConnectedThread Writer;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
public BluetoothAdapter mblue;
public void connect(View sender)
{
mblue = BluetoothAdapter.getDefaultAdapter();
int REQUEST_ENABLE_BT = 1;
final TextView er = (TextView)findViewById(R.id.Error);
if(mblue == null)
er.setText("No Bluetooth!");
else if (mblue.isEnabled()) {
er.setText(mblue.getAddress() + " " + mblue.getName());
}
else{
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(en