愿君学长松,慎勿作桃李。这篇文章主要讲述Android蓝牙聊天示例无效,无法连接设备相关的知识,希望能为你提供帮助。
我在https://developer.android.com/samples/BluetoothChat/index.html中一直在尝试蓝牙聊天,但我的设备(Nexus 7)无法使用该示例配对/连接到我的笔记本电脑(华硕)。
我正在使用示例中的默认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
【Android蓝牙聊天示例无效,无法连接设备】我也尝试了各种其他蓝牙聊天示例,但每次都面临“无法连接设备”。
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
- Android nougat(超过7.0.0)的BLE(蓝牙低功耗)无法读取数据
- 如何使用applescript打开带有quicktime播放器的MP3()
- Appium(连接到127.0.0.1:4723 [/127.0.0.1]失败:连接被拒绝:连接)
- 使用高CPU时通知。通过AppleScript或Automator()
- 在appengine-web.xml中显示“URI未注册”的Android Studio lint()
- Google Apps脚本 - 复制到现有电子表格
- 带有Firebase的Google App Engine-无法添加依赖项
- 差异b / w在AsyncTask Android中取消(true)和取消(false)