Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/319.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 蓝牙套接字连接未显示错误,但不工作_Java_Android_Bluetooth_Android Bluetooth - Fatal编程技术网

Java 蓝牙套接字连接未显示错误,但不工作

Java 蓝牙套接字连接未显示错误,但不工作,java,android,bluetooth,android-bluetooth,Java,Android,Bluetooth,Android Bluetooth,我正在尝试将我的手机与模蓝牙HC-05连接,我的手机请求与模蓝牙连接,我正在尝试通过MAC地址直接建立连接,而不检查可用设备。我没有收到任何错误,但我的设备没有连接。 这是我的密码- public class ConexionBluetooth extends Thread { `public static UUID id=UUID.randomUUID(); private final BluetoothSocket sock; private final BluetoothDevi

我正在尝试将我的手机与模蓝牙HC-05连接,我的手机请求与模蓝牙连接,我正在尝试通过MAC地址直接建立连接,而不检查可用设备。我没有收到任何错误,但我的设备没有连接。
这是我的密码-

public class ConexionBluetooth extends Thread
{
 `public static UUID id=UUID.randomUUID();
  private final BluetoothSocket sock;
  private final BluetoothDevice celular;
  public ConexionBluetooth(BluetoothDevice entrada)`
  {
   `celular=entrada;
    BluetoothSocket tmp=null;
    try {
        tmp = entrada.createRfcommSocketToServiceRecord(id);
    } catch (IOException e) { }
    sock = tmp;
   }                                                                                       
public void run()
{
    try {
        sock.connect();
    } catch (IOException closeException)
    {}
    return;
}
public void cancel()
{
    try{
        sock.close();
    }
    catch (IOException e)
    {}
    return;
}
}

在我的班级里,我有这些

final BluetoothDevice dispositivoMAC = enlace.getRemoteDevice("98:D3:31:60:23:DE"); //HC-05 MODULO MAC
为了将mac发送到我的班级,我有以下代码

ConexionBluetooth conectar=new ConexionBluetooth(dispositivoMAC);
conectar.start();
我与API BLUETOOTH一起使用的类,我有更多的类,但属于应用程序(bundler、BroadCast等)


我的手机是客户,我的hc-05是服务生。请把完整的代码发出来。您正在使用哪个蓝牙库??bluetooth.BluetoothAdapter;蓝牙设备;蓝牙.蓝牙插座;请检查设备可见性和范围您是否在应用程序的权限中定义了您正在使用蓝牙?
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothSocket;