Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/351.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 android Bluetooth服务器在发现中不可见_Java_Android - Fatal编程技术网

Java android Bluetooth服务器在发现中不可见

Java android Bluetooth服务器在发现中不可见,java,android,Java,Android,所以我写了一个简单的蓝牙服务器,但我不能看穿蓝牙设置,也不能看穿其他davice的蓝牙广播接收器。 我想创建一个叫phoneTo的蓝牙davice 这是我的服务器代码 class AcceptThread extends Thread { private final BluetoothServerSocket mmServerSocket; public AcceptThread() { BluetoothServerSocket tmp = null; try {

所以我写了一个简单的蓝牙服务器,但我不能看穿蓝牙设置,也不能看穿其他davice的蓝牙广播接收器。 我想创建一个叫phoneTo的蓝牙davice 这是我的服务器代码

class AcceptThread extends Thread {
private final BluetoothServerSocket mmServerSocket;

public AcceptThread() {
  
    BluetoothServerSocket tmp = null;
    try {
        // MY_UUID is the app's UUID string, also used by the client code.
        BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
        tmp = bluetoothAdapter.listenUsingRfcommWithServiceRecord("phonTo",   UUID.randomUUID());//phonTo is the name I want the device to have 
    } catch (IOException e) {
        Log.e("ok", "Socket's listen() method failed", e);
    }
    mmServerSocket = tmp;
}
 public void run() {
    BluetoothSocket socket = null;
    // Keep listening until exception occurs or a socket is returned.
    while (true) {
        try {
            socket = mmServerSocket.accept();
        } catch (IOException e) {
            Log.e("ok", "Socket's accept() method failed", e);
            break;
        }
而我只是简单地运行线程

        AcceptThread th=new AcceptThread();
        new Thread(th).start();
但无法通过蓝牙看到任何正在扫描的设备。 我用了 作为我的学习资源