我正在尝试创建蓝牙连接.
我可以搜索附近的设备但是当我尝试连接时出现错误,我不明白:
01-03 00:55:06.909 6654-6654/com.bluetooth.prova3.listdiscovery D/CONNECTTHREAD: Could not close connection:java.io.IOException: read failed, socket might closed or timeout, read ret: -1
Run Code Online (Sandbox Code Playgroud)
我有两个连接类,一个接收设备并执行连接,另一个用于连接.
ConexionActivity.Java
package com.bluetooth.prova3.listdiscovery;
***Imports*****
public class ConexionActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_conexion);
//Aqui rebo el dispositiu que he seleccionat per conectarme
Intent intent = getIntent();
BluetoothDevice bluetoothDevice = intent.getExtras().getParcelable("btdevice");
//mostro el nom per la pantalla amb un text view
TextView MacAddress = (TextView)findViewById(R.id.MAC);
String aaaa = bluetoothDevice.getName() + "\n" + …Run Code Online (Sandbox Code Playgroud)