0

我刚刚使用 Android 和蓝牙完成了我的应用程序的开发,您可以发送消息共享文件并与蓝牙聊天。这是一个非常奇怪的应用程序,每次它显示一个错误,而其他时候它工作得很好。这是我的问题的顶部

E/BluetoothEventLoop.cpp(298): onCreateDeviceResult: D-Bus error: org.bluez.Error.AlreadyExists (Already Exists)`

第二个错误:

服务发现失败[Ljava.lang.StackTraceElement

我的代码:

    private BluetoothSocket getLaSocketConnecte(BluetoothDevice myBtServer, UUID uuidToTry)           
    { 
      BluetoothSocket myBSock; 
      try 
      { 
        if (BtAdapter.isDiscovering()) 
        { 
          BtAdapter.cancelDiscovery(); 
        } 
        myBSock = myBtServer.createRfcommSocketToServiceRecord(uuidToTry);
        myBSock.connect(); 
        return myBSock; 
      } catch (Exception e) { 
        Log.i(TAG,"IOException . Msg d'erreur :" + e.getMessage()+ e.getStackTrace()); 
      } 
      return null; 
    }

这是日志:

04-01 20:38:28.079: I/Connexion(9240): Msg d'erreur : Msg d erreur 

:Service discovery failed
04-01 20:38:28.079: I/Connexion(9240): java.io.IOException: Service discovery failed
04-01 20:38:28.079: I/Connexion(9240):  at android.bluetooth.BluetoothSocket$SdpHelper.doSdp(BluetoothSocket.java:403)
04-01 20:38:28.079: I/Connexion(9240):  at android.bluetooth.BluetoothSocket.connect(BluetoothSocket.java:213)
            myBSock.connect();
04-01 20:38:28.079: I/Connexion(9240):  at com.Android.Bt.Connexion.getLaSocketConnecte(Connexion.java:190)
04-01 20:38:28.079: I/Connexion(9240):  at com.Android.Bt.Connexion.connecterA(Connexion.java:149)
            btSock = getLaSocketConnecte(btDevice, uuidList.get(i));
04-01 20:38:28.079: I/Connexion(9240):  at com.Android.Bt.Connexion.ConnecterTousLesAppreils(Connexion.java:293)
            connecterA(device.getKey());
04-01 20:38:28.079: I/Connexion(9240):  at com.Android.Bt.Connexion.EnvoyeBroadcastMsg(Connexion.java:428)
04-01 20:38:28.079: I/Connexion(9240):  at com.Android.Bt.Connexion.broadcastMessage(Connexion.java:205)
04-01 20:38:28.079: I/Connexion(9240):  at com.Android.Bt.BtPaquetReceiver.onReceive(BtPaquetReceiver.java:28)

你能帮我找出解决方案吗?

谢谢 :)


4

1 回答 1

0

当时的问题与蓝牙 API 有关!

于 2015-08-23T11:22:32.347 回答