Android 蓝牙连接 - 服务发现失败 [英] Android Bluetooth Connection - Service Discovery Failed
问题描述
我正在尝试创建一个基本的蓝牙应用程序,用于测试设备.
I'm trying to create a basic bluetooth application, for testing the device.
我从 developer.android 得到了代码.这是链接:http://developer.android.com/guide/topics/connectivity/bluetooth.html#ConnectingDevices
I got the code from developer.android. Here is the link : http://developer.android.com/guide/topics/connectivity/bluetooth.html#ConnectingDevices
这是我的线程代码的运行部分:
Here is run part of my thread code:
public void run() {
mBluetoothAdapter.cancelDiscovery();
Log.i(TAG, "Discovery Cancel!");
try {
Log.i(TAG, "Connection Started");
mmSocket.connect();
Log.i(TAG, "Connection Ended");
} catch (IOException e) {
try {
Log.e(TAG, "Connection Failed", e);
mmSocket.close();
} catch (IOException e2) {
Log.e(TAG, "Connection Close Failed", e2);
}
return;
}
无论我尝试过什么 mmSocket.connect();
都行不通.总是抛出一个 IOException 并且我从我的 logcat 得到那个日志:
Whatever I have tried mmSocket.connect();
never works. Always throws an IOException and I get that log from my logcat:
java.io.IOException:服务发现失败
在 android.bluetooth.BluetoothSocket$SdpHelper.doSdp(BluetoothSocket.java:403)
在 android.bluetooth.BluetoothSocket.connect(BluetoothSocket.java:213)
我看过这些文章,也试过写的东西,都没有解决我的问题.
I've looked at these articles, and tried the written things, none of them has solved my problem.
Android 蓝牙 java.io.IOException:连接被拒绝?
顺便说一句,我正在开发 android ics 4.0.4.
Btw I'm working on android ics 4.0.4.
我知道这不是设备问题,因为我已经在不同的设备上尝试过这个应用程序.
I know that is not device problem, cause I've tried this app on different devices.
推荐答案
我不知道,我仍然不明白 UUID 的东西,但问题是 UUID.我正在使用从内核日志中获得的 UUID,它是 00001105-0000-1000-8000-00805F9B34FB
.
I don't know and I still don't understand the UUID stuff but the problem was the UUID. I'm using the UUID which I got from the kernel logs and it is 00001105-0000-1000-8000-00805F9B34FB
.
这篇关于Android 蓝牙连接 - 服务发现失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!