我刚用Android和蓝牙开发我的应用程序,你可以发送消息共享文件和蓝牙聊天。这是一个非常奇怪的应用程序每次显示错误和其他时间它完美的工作。这是我遇到的问题
E / BluetoothEventLoop.cpp(298):onCreateDeviceResult:D-Bus错误:org.bluez.Error.AlreadyExists(已经存在)`
第二个错误:
服务发现失败[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)
你能帮我解决一下这个问题吗?
谢谢:)
答案 0 :(得分:0)
当时的问题与蓝牙API有关!