小编Jos*_* M.的帖子

蓝牙连接失败:读取失败,套接字可能关闭或超时,读取ret:-1

我正在尝试创建蓝牙连接.

我可以搜索附近的设备但是当我尝试连接时出现错误,我不明白:

logcat的

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)

java android bluetooth

6
推荐指数
2
解决办法
6007
查看次数

标签 统计

android ×1

bluetooth ×1

java ×1