gpt4 book ai didi

Android 蓝牙聊天示例不起作用,无法连接设备

转载 作者:行者123 更新时间:2023-11-29 19:09:26 25 4
gpt4 key购买 nike

我一直在按照 https://developer.android.com/samples/BluetoothChat/index.html 中的示例尝试蓝牙聊天,但是我的设备 (Nexus 7) 无法使用示例配对/连接到我的笔记本电脑 (ASUS)。

我使用示例中的默认 UUID。我还需要修改代码才能使其正常工作吗?以下是我尝试连接时从 logcat 得到的结果。

08-26 17:33:16.259 3834-3834/? I/art: Late-enabling -Xcheck:jni
08-26 17:33:16.510 3834-3834/com.example.android.bluetoothchat
I/MainActivity: Ready
08-26 17:33:16.513 3834-3834/com.example.android.bluetoothchat
D/BluetoothChatService: start
08-26 17:33:16.521 3834-3834/com.example.android.bluetoothchat
W/BluetoothAdapter: getBluetoothService() called with no
BluetoothManagerCallback
08-26 17:33:16.526 3834-3864/com.example.android.bluetoothchat
D/BluetoothChatService: Socket Type: SecureBEGIN mAcceptThreadThread[Thread-
479,5,main]
08-26 17:33:16.526 3834-3834/com.example.android.bluetoothchat
W/BluetoothAdapter: getBluetoothService() called with no
BluetoothManagerCallback
08-26 17:33:16.529 3834-3834/com.example.android.bluetoothchat
D/BluetoothChatService: updateUserInterfaceTitle() 0 -> 1
08-26 17:33:16.529 3834-3865/com.example.android.bluetoothchat
D/BluetoothChatService: Socket Type: InsecureBEGIN
mAcceptThreadThread[Thread-480,5,main]
08-26 17:33:16.543 3834-3866/com.example.android.bluetoothchat
D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: false
08-26 17:33:16.554 3834-3834/com.example.android.bluetoothchat D/Atlas:
Validating map...
08-26 17:33:16.640 3834-3866/com.example.android.bluetoothchat D/libEGL:
loaded /system/lib/egl/libEGL_tegra.so
08-26 17:33:16.657 3834-3866/com.example.android.bluetoothchat D/libEGL:
loaded /system/lib/egl/libGLESv1_CM_tegra.so
08-26 17:33:16.691 3834-3866/com.example.android.bluetoothchat D/libEGL:
loaded /system/lib/egl/libGLESv2_tegra.so
08-26 17:33:16.738 3834-3866/com.example.android.bluetoothchat
I/OpenGLRenderer: Initialized EGL, version 1.4
08-26 17:33:16.748 3834-3866/com.example.android.bluetoothchat
D/OpenGLRenderer: Enabling debug mode 0
08-26 17:33:20.384 3834-3834/com.example.android.bluetoothchat
D/DeviceListActivity: doDiscovery()
08-26 17:33:25.394 3834-3834/com.example.android.bluetoothchat
D/BluetoothChatService: connect to: 28:C2:DD:8C:30:BC
08-26 17:33:25.401 3834-3834/com.example.android.bluetoothchat
D/BluetoothChatService: updateUserInterfaceTitle() 1 -> 2
08-26 17:33:25.402 3834-4016/com.example.android.bluetoothchat
I/BluetoothChatService: BEGIN mConnectThread SocketType:Secure
08-26 17:33:25.423 3834-4016/com.example.android.bluetoothchat
W/BluetoothAdapter: getBluetoothService() called with no
BluetoothManagerCallback
08-26 17:33:27.479 3834-4016/com.example.android.bluetoothchat
D/BluetoothChatService: updateUserInterfaceTitle() 2 -> 0
08-26 17:33:27.479 3834-4016/com.example.android.bluetoothchat
D/BluetoothChatService: start
08-26 17:33:27.479 3834-4016/com.example.android.bluetoothchat
D/BluetoothChatService: updateUserInterfaceTitle() 0 -> 0

我也尝试过各种其他蓝牙聊天示例,但每次都面临“无法连接设备”。

 I/BluetoothChatService: BEGIN mConnectThread SocketType:Secure
08-26 17:33:25.423 3834-4016/com.example.android.bluetoothchat
W/BluetoothAdapter: getBluetoothService() called with no
BluetoothManagerCallback

会不会是这个问题导致设备无法成功配对?任何使这项工作正常进行的建议都很棒!

最佳答案

这可能是 UUID 的问题。

尝试使用 UUID.fromString("00001101-0000-1000-8000-00805f9b34fb")

详见https://www.bluetooth.com/specifications/assigned-numbers/service-discovery

关于Android 蓝牙聊天示例不起作用,无法连接设备,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45894030/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com