Android 无法使用蓝牙聊天示例连接到设备

Android 无法使用蓝牙聊天示例连接到设备,android,bluetooth,Android,Bluetooth,我想创建应用程序,通过蓝牙连接到OBDII设备。首先,我想将我的应用程序建立在蓝牙聊天示例的基础上,然后开始构建自己的应用程序。我下载了蓝牙聊天示例。我试图连接到设备OBDII,但无法连接。我尝试连接到其他设备,如GPS蓝牙,它也失败了。来自play store的应用程序 蓝牙终端 连接到前面提到的这两个设备,没有任何问题。我可以和他们交谈并收到短信。我应该如何使用蓝牙示例才能工作 AndroidManifest.xml <?xml version="1.0" encoding="UTF-

我想创建应用程序,通过蓝牙连接到OBDII设备。首先,我想将我的应用程序建立在蓝牙聊天示例的基础上,然后开始构建自己的应用程序。我下载了蓝牙聊天示例。我试图连接到设备OBDII,但无法连接。我尝试连接到其他设备,如GPS蓝牙,它也失败了。来自play store的应用程序

蓝牙终端

连接到前面提到的这两个设备,没有任何问题。我可以和他们交谈并收到短信。我应该如何使用蓝牙示例才能工作

AndroidManifest.xml

<?xml version="1.0" encoding="UTF-8"?>
<!--
 Copyright 2014 The Android Open Source Project

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-->

<manifest
    package="com.example.android.bluetoothchat"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:versionCode="1"
    android:versionName="1.0">

    <!-- Min/target SDK versions (<uses-sdk>) managed by build.gradle -->

    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
    <uses-permission android:name="android.permission.BLUETOOTH"/>

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme">

        <activity
            android:name=".MainActivity"
            android:configChanges="orientation|keyboardHidden"
            android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>

        <activity
            android:name=".DeviceListActivity"
            android:configChanges="orientation|keyboardHidden"
            android:label="@string/select_device"
            android:theme="@android:style/Theme.Holo.Dialog"/>

    </application>

</manifest>
logcat

07-07 17:46:52.463  12696-12696/com.example.android.bluetoothchat D/dalvikvm﹕ Late-enabling CheckJNI
07-07 17:46:52.783  12696-12696/com.example.android.bluetoothchat D/AbsListView﹕ Get MotionRecognitionManager
07-07 17:46:52.833  12696-12696/com.example.android.bluetoothchat I/MainActivity﹕ Ready
07-07 17:46:52.833  12696-12696/com.example.android.bluetoothchat D/BluetoothChatService﹕ start
07-07 17:46:52.833  12696-12696/com.example.android.bluetoothchat D/BluetoothChatService﹕ setState() 0 -> 1
07-07 17:46:52.933  12696-12696/com.example.android.bluetoothchat W/BluetoothAdapter﹕ getBluetoothService() called with no BluetoothManagerCallback
07-07 17:46:52.943  12696-12711/com.example.android.bluetoothchat D/BluetoothChatService﹕ Socket Type: SecureBEGIN mAcceptThreadThread[Thread-28376,5,main]
07-07 17:46:52.943  12696-12696/com.example.android.bluetoothchat W/BluetoothAdapter﹕ getBluetoothService() called with no BluetoothManagerCallback
07-07 17:46:52.943  12696-12712/com.example.android.bluetoothchat D/BluetoothChatService﹕ Socket Type: InsecureBEGIN mAcceptThreadThread[Thread-28377,5,main]
07-07 17:46:53.023  12696-12696/com.example.android.bluetoothchat D/libEGL﹕ loaded /system/lib/egl/libEGL_MRVL.so
07-07 17:46:53.033  12696-12696/com.example.android.bluetoothchat D/libEGL﹕ loaded /system/lib/egl/libGLESv1_CM_MRVL.so
07-07 17:46:53.084  12696-12696/com.example.android.bluetoothchat D/libEGL﹕ loaded /system/lib/egl/libGLESv2_MRVL.so
07-07 17:46:53.114  12696-12696/com.example.android.bluetoothchat D/GC﹕ <tid=12696> OES20 ===> GC Version   : GC Ver rls_pxa988_KK44_GC13.25
07-07 17:46:53.144  12696-12696/com.example.android.bluetoothchat D/OpenGLRenderer﹕ Enabling debug mode 0
07-07 17:47:01.552  12696-12696/com.example.android.bluetoothchat W/ResourceType﹕ Invalid package identifier when getting bag for resource number 0xffffffff
07-07 17:47:01.562  12696-12696/com.example.android.bluetoothchat W/ResourceType﹕ Invalid package identifier when getting bag for resource number 0xffffffff
07-07 17:47:01.572  12696-12696/com.example.android.bluetoothchat D/AbsListView﹕ Get MotionRecognitionManager
07-07 17:47:01.572  12696-12696/com.example.android.bluetoothchat W/ResourceType﹕ Invalid package identifier when getting bag for resource number 0xffffffff
07-07 17:47:01.582  12696-12696/com.example.android.bluetoothchat W/ResourceType﹕ Invalid package identifier when getting bag for resource number 0xffffffff
07-07 17:47:01.592  12696-12696/com.example.android.bluetoothchat W/ResourceType﹕ Invalid package identifier when getting bag for resource number 0xffffffff
07-07 17:47:01.592  12696-12696/com.example.android.bluetoothchat W/ResourceType﹕ Invalid package identifier when getting bag for resource number 0xffffffff
07-07 17:47:01.622  12696-12696/com.example.android.bluetoothchat W/ResourceType﹕ Invalid package identifier when getting bag for resource number 0xffffffff
07-07 17:47:01.632  12696-12696/com.example.android.bluetoothchat W/ResourceType﹕ Invalid package identifier when getting bag for resource number 0xffffffff
07-07 17:47:02.803  12696-12696/com.example.android.bluetoothchat D/AbsListView﹕ onDetachedFromWindow
07-07 17:47:02.823  12696-12696/com.example.android.bluetoothchat E/ViewRootImpl﹕ sendUserActionEvent() mView == null
07-07 17:47:02.833  12696-12696/com.example.android.bluetoothchat D/ProgressBar﹕ setProgressDrawable drawableHeight = 21
07-07 17:47:02.873  12696-12696/com.example.android.bluetoothchat D/AbsListView﹕ Get MotionRecognitionManager
07-07 17:47:02.883  12696-12696/com.example.android.bluetoothchat D/AbsListView﹕ Get MotionRecognitionManager
07-07 17:47:02.983  12696-12696/com.example.android.bluetoothchat D/ProgressBar﹕ updateDrawableBounds: left = 0
07-07 17:47:02.983  12696-12696/com.example.android.bluetoothchat D/ProgressBar﹕ updateDrawableBounds: top = 0
07-07 17:47:02.983  12696-12696/com.example.android.bluetoothchat D/ProgressBar﹕ updateDrawableBounds: right = 21
07-07 17:47:02.983  12696-12696/com.example.android.bluetoothchat D/ProgressBar﹕ updateDrawableBounds: bottom = 21
07-07 17:47:04.525  12696-12696/com.example.android.bluetoothchat D/ProgressBar﹕ updateDrawableBounds: left = 0
07-07 17:47:04.525  12696-12696/com.example.android.bluetoothchat D/ProgressBar﹕ updateDrawableBounds: top = 0
07-07 17:47:04.525  12696-12696/com.example.android.bluetoothchat D/ProgressBar﹕ updateDrawableBounds: right = 615
07-07 17:47:04.525  12696-12696/com.example.android.bluetoothchat D/ProgressBar﹕ updateDrawableBounds: bottom = 21
07-07 17:47:04.525  12696-12696/com.example.android.bluetoothchat D/ProgressBar﹕ updateDrawableBounds: mProgressDrawable.setBounds()
07-07 17:47:04.535  12696-12696/com.example.android.bluetoothchat D/BluetoothChatService﹕ connect to: 00:15:4B:10:9C:86
07-07 17:47:04.545  12696-12696/com.example.android.bluetoothchat D/BluetoothChatService﹕ setState() 1 -> 2
07-07 17:47:04.545  12696-12908/com.example.android.bluetoothchat I/BluetoothChatService﹕ BEGIN mConnectThread SocketType:Insecure
07-07 17:47:04.545  12696-12908/com.example.android.bluetoothchat D/BluetoothUtils﹕ isSocketAllowedBySecurityPolicy start : device null
07-07 17:47:04.545  12696-12908/com.example.android.bluetoothchat D/BluetoothSocket﹕ GlobalConfig.GLOBALCONFIG_BT_IT_POLICY_FEATURE = true
07-07 17:47:04.545  12696-12908/com.example.android.bluetoothchat W/BluetoothAdapter﹕ getBluetoothService() called with no BluetoothManagerCallback
07-07 17:47:04.565  12696-12908/com.example.android.bluetoothchat D/BluetoothSocket﹕ connect(), SocketState: INIT, mPfd: {ParcelFileDescriptor: FileDescriptor[56]}
07-07 17:47:04.605  12696-12696/com.example.android.bluetoothchat D/AbsListView﹕ onDetachedFromWindow
07-07 17:47:04.605  12696-12696/com.example.android.bluetoothchat D/AbsListView﹕ onDetachedFromWindow
07-07 17:47:06.797  12696-12908/com.example.android.bluetoothchat D/BluetoothChatService﹕ start
07-07 17:47:06.797  12696-12908/com.example.android.bluetoothchat D/BluetoothChatService﹕ setState() 2 -> 1
07-07 17:46:52.463 12696-12696/com.example.android.bluetoothchat D/dalvikvm﹕ 延迟启用CheckJNI
07-07 17:46:52.783 12696-12696/com.example.android.bluetoothchat D/AbsListView﹕ 获取MotionRecognitionManager
07-07 17:46:52.833 12696-12696/com.example.android.bluetoothchat I/main活动﹕ 准备好的
07-07 17:46:52.833 12696-12696/com.example.android.bluetoothchat D/BluetoothChatService﹕ 开始
07-07 17:46:52.833 12696-12696/com.example.android.bluetoothchat D/BluetoothChatService﹕ 设置状态()0->1
07-07 17:46:52.933 12696-12696/com.example.android.bluetoothchat W/BluetoothAdapter﹕ 在没有BluetoothManagerCallback的情况下调用getBluetoothService()
07-07 17:46:52.943 12696-12711/com.example.android.bluetoothchat D/BluetoothChatService﹕ 套接字类型:SecureBeagin mAcceptThreadThread[Thread-28376,5,main]
07-07 17:46:52.943 12696-12696/com.example.android.bluetoothchat W/BluetoothAdapter﹕ 在没有BluetoothManagerCallback的情况下调用getBluetoothService()
07-07 17:46:52.943 12696-12712/com.example.android.bluetoothchat D/BluetoothChatService﹕ 套接字类型:不安全的Begin mAcceptThreadThread[Thread-28377,5,main]
07-07 17:46:53.023 12696-12696/com.example.android.bluetoothchat D/libEGL﹕ 已加载/system/lib/egl/libEGL_MRVL.so
07-07 17:46:53.033 12696-12696/com.example.android.bluetoothchat D/libEGL﹕ loaded/system/lib/egl/libGLESv1_CM_MRVL.so
07-07 17:46:53.084 12696-12696/com.example.android.bluetoothchat D/libEGL﹕ loaded/system/lib/egl/libGLESv2_MRVL.so
07-07 17:46:53.114 12696-12696/com.example.android.bluetoothchat D/GC﹕  OES20==>GC版本:GC版本rls\U pxa988\U KK44\U GC13.25
07-07 17:46:53.144 12696-12696/com.example.android.bluetoothchat D/opengld﹕ 正在启用调试模式0
07-07 17:47:01.552 12696-12696/com.example.android.bluetoothchat W/ResourceType﹕ 获取资源号0xFFFFFF的包时包标识符无效
07-07 17:47:01.562 12696-12696/com.example.android.bluetoothchat W/ResourceType﹕ 获取资源号0xFFFFFF的包时包标识符无效
07-07 17:47:01.572 12696-12696/com.example.android.bluetoothchat D/AbsListView﹕ 获取MotionRecognitionManager
07-07 17:47:01.572 12696-12696/com.example.android.bluetoothchat W/ResourceType﹕ 获取资源号0xFFFFFF的包时包标识符无效
07-07 17:47:01.582 12696-12696/com.example.android.bluetoothchat W/ResourceType﹕ 获取资源号0xFFFFFF的包时包标识符无效
07-07 17:47:01.592 12696-12696/com.example.android.bluetoothchat W/ResourceType﹕ 获取资源号0xFFFFFF的包时包标识符无效
07-07 17:47:01.592 12696-12696/com.example.android.bluetoothchat W/ResourceType﹕ 获取资源号0xFFFFFF的包时包标识符无效
07-07 17:47:01.622 12696-12696/com.example.android.bluetoothchat W/ResourceType﹕ 获取资源号0xFFFFFF的包时包标识符无效
07-07 17:47:01.632 12696-12696/com.example.android.bluetoothchat W/ResourceType﹕ 获取资源号0xFFFFFF的包时包标识符无效
07-07 17:47:02.803 12696-12696/com.example.android.bluetoothchat D/AbsListView﹕ onDetachedFromWindow
07-07 17:47:02.823 12696-12696/com.example.android.bluetoothchat E/ViewRootImpl﹕ sendUserActionEvent()mView==null
07-07 17:47:02.833 12696-12696/com.example.android.bluetoothchat D/ProgressBar﹕ setProgressDrawable可拉伸高度=21
07-07 17:47:02.873 12696-12696/com.example.android.bluetoothchat D/AbsListView﹕ 获取MotionRecognitionManager
07-07 17:47:02.883 12696-12696/com.example.android.bluetoothchat D/AbsListView﹕ 获取MotionRecognitionManager
07-07 17:47:02.983 12696-12696/com.example.android.bluetoothchat D/ProgressBar﹕ updateDrawableBounds:左=0
07-07 17:47:02.983 12696-12696/com.example.android.bluetoothchat D/ProgressBar﹕ updateDrawableBounds:top=0
07-07 17:47:02.983 12696-12696/com.example.android.bluetoothchat D/ProgressBar﹕ updateDrawableBounds:right=21
07-07 17:47:02.983 12696-12696/com.example.android.bluetoothchat D/ProgressBar﹕ updateDrawableBounds:bottom=21
07-07 17:47:04.525 12696-12696/com.example.android.bluetoothchat D/ProgressBar﹕ updateDrawableBounds:左=0
07-07 17:47:04.525 12696-12696/com.example.android.bluetoothchat D/ProgressBar﹕ updateDrawableBounds:top=0
07-07 17:47:04.525 12696-12696/com.example.android.bluetoothchat D/ProgressBar﹕ updateDrawableBounds:right=615
07-07 17:47:04.525 12696-12696/com.example.android.bluetoothchat D/ProgressBar﹕ updateDrawableBounds:bottom=21
07-07 17:47:04.525 12696-12696/com.example.android.bluetoothchat D/ProgressBar﹕ updateDrawableBounds:mProgressDrawable.setBounds()
07-07 17:47:04.535 12696-12696/com.example.android.bluetoothchat D/BluetoothChatService﹕ 连接到:00:15:4B:10:9C:86
07-07 17:47:04.545 12696-12696/com.example.android.bluetoothchat D/BluetoothChatService﹕ 设置状态()1->2
07-07 17:47:04.545 12696-12908/com.example.android.bluetoothchat I/BluetoothChatService﹕ BEGIN mConnectThread SocketType:不安全
07-07 17:47:04.545 12696-12908/com.example.android.bluetoothchat D/BluetoothUtils﹕ IsSocketAllowedBySecurity策略启动:设备null
07-07 17:47:04.545 12696-12908/com.example.android.bl
07-07 17:46:52.463  12696-12696/com.example.android.bluetoothchat D/dalvikvm﹕ Late-enabling CheckJNI
07-07 17:46:52.783  12696-12696/com.example.android.bluetoothchat D/AbsListView﹕ Get MotionRecognitionManager
07-07 17:46:52.833  12696-12696/com.example.android.bluetoothchat I/MainActivity﹕ Ready
07-07 17:46:52.833  12696-12696/com.example.android.bluetoothchat D/BluetoothChatService﹕ start
07-07 17:46:52.833  12696-12696/com.example.android.bluetoothchat D/BluetoothChatService﹕ setState() 0 -> 1
07-07 17:46:52.933  12696-12696/com.example.android.bluetoothchat W/BluetoothAdapter﹕ getBluetoothService() called with no BluetoothManagerCallback
07-07 17:46:52.943  12696-12711/com.example.android.bluetoothchat D/BluetoothChatService﹕ Socket Type: SecureBEGIN mAcceptThreadThread[Thread-28376,5,main]
07-07 17:46:52.943  12696-12696/com.example.android.bluetoothchat W/BluetoothAdapter﹕ getBluetoothService() called with no BluetoothManagerCallback
07-07 17:46:52.943  12696-12712/com.example.android.bluetoothchat D/BluetoothChatService﹕ Socket Type: InsecureBEGIN mAcceptThreadThread[Thread-28377,5,main]
07-07 17:46:53.023  12696-12696/com.example.android.bluetoothchat D/libEGL﹕ loaded /system/lib/egl/libEGL_MRVL.so
07-07 17:46:53.033  12696-12696/com.example.android.bluetoothchat D/libEGL﹕ loaded /system/lib/egl/libGLESv1_CM_MRVL.so
07-07 17:46:53.084  12696-12696/com.example.android.bluetoothchat D/libEGL﹕ loaded /system/lib/egl/libGLESv2_MRVL.so
07-07 17:46:53.114  12696-12696/com.example.android.bluetoothchat D/GC﹕ <tid=12696> OES20 ===> GC Version   : GC Ver rls_pxa988_KK44_GC13.25
07-07 17:46:53.144  12696-12696/com.example.android.bluetoothchat D/OpenGLRenderer﹕ Enabling debug mode 0
07-07 17:47:01.552  12696-12696/com.example.android.bluetoothchat W/ResourceType﹕ Invalid package identifier when getting bag for resource number 0xffffffff
07-07 17:47:01.562  12696-12696/com.example.android.bluetoothchat W/ResourceType﹕ Invalid package identifier when getting bag for resource number 0xffffffff
07-07 17:47:01.572  12696-12696/com.example.android.bluetoothchat D/AbsListView﹕ Get MotionRecognitionManager
07-07 17:47:01.572  12696-12696/com.example.android.bluetoothchat W/ResourceType﹕ Invalid package identifier when getting bag for resource number 0xffffffff
07-07 17:47:01.582  12696-12696/com.example.android.bluetoothchat W/ResourceType﹕ Invalid package identifier when getting bag for resource number 0xffffffff
07-07 17:47:01.592  12696-12696/com.example.android.bluetoothchat W/ResourceType﹕ Invalid package identifier when getting bag for resource number 0xffffffff
07-07 17:47:01.592  12696-12696/com.example.android.bluetoothchat W/ResourceType﹕ Invalid package identifier when getting bag for resource number 0xffffffff
07-07 17:47:01.622  12696-12696/com.example.android.bluetoothchat W/ResourceType﹕ Invalid package identifier when getting bag for resource number 0xffffffff
07-07 17:47:01.632  12696-12696/com.example.android.bluetoothchat W/ResourceType﹕ Invalid package identifier when getting bag for resource number 0xffffffff
07-07 17:47:02.803  12696-12696/com.example.android.bluetoothchat D/AbsListView﹕ onDetachedFromWindow
07-07 17:47:02.823  12696-12696/com.example.android.bluetoothchat E/ViewRootImpl﹕ sendUserActionEvent() mView == null
07-07 17:47:02.833  12696-12696/com.example.android.bluetoothchat D/ProgressBar﹕ setProgressDrawable drawableHeight = 21
07-07 17:47:02.873  12696-12696/com.example.android.bluetoothchat D/AbsListView﹕ Get MotionRecognitionManager
07-07 17:47:02.883  12696-12696/com.example.android.bluetoothchat D/AbsListView﹕ Get MotionRecognitionManager
07-07 17:47:02.983  12696-12696/com.example.android.bluetoothchat D/ProgressBar﹕ updateDrawableBounds: left = 0
07-07 17:47:02.983  12696-12696/com.example.android.bluetoothchat D/ProgressBar﹕ updateDrawableBounds: top = 0
07-07 17:47:02.983  12696-12696/com.example.android.bluetoothchat D/ProgressBar﹕ updateDrawableBounds: right = 21
07-07 17:47:02.983  12696-12696/com.example.android.bluetoothchat D/ProgressBar﹕ updateDrawableBounds: bottom = 21
07-07 17:47:04.525  12696-12696/com.example.android.bluetoothchat D/ProgressBar﹕ updateDrawableBounds: left = 0
07-07 17:47:04.525  12696-12696/com.example.android.bluetoothchat D/ProgressBar﹕ updateDrawableBounds: top = 0
07-07 17:47:04.525  12696-12696/com.example.android.bluetoothchat D/ProgressBar﹕ updateDrawableBounds: right = 615
07-07 17:47:04.525  12696-12696/com.example.android.bluetoothchat D/ProgressBar﹕ updateDrawableBounds: bottom = 21
07-07 17:47:04.525  12696-12696/com.example.android.bluetoothchat D/ProgressBar﹕ updateDrawableBounds: mProgressDrawable.setBounds()
07-07 17:47:04.535  12696-12696/com.example.android.bluetoothchat D/BluetoothChatService﹕ connect to: 00:15:4B:10:9C:86
07-07 17:47:04.545  12696-12696/com.example.android.bluetoothchat D/BluetoothChatService﹕ setState() 1 -> 2
07-07 17:47:04.545  12696-12908/com.example.android.bluetoothchat I/BluetoothChatService﹕ BEGIN mConnectThread SocketType:Insecure
07-07 17:47:04.545  12696-12908/com.example.android.bluetoothchat D/BluetoothUtils﹕ isSocketAllowedBySecurityPolicy start : device null
07-07 17:47:04.545  12696-12908/com.example.android.bluetoothchat D/BluetoothSocket﹕ GlobalConfig.GLOBALCONFIG_BT_IT_POLICY_FEATURE = true
07-07 17:47:04.545  12696-12908/com.example.android.bluetoothchat W/BluetoothAdapter﹕ getBluetoothService() called with no BluetoothManagerCallback
07-07 17:47:04.565  12696-12908/com.example.android.bluetoothchat D/BluetoothSocket﹕ connect(), SocketState: INIT, mPfd: {ParcelFileDescriptor: FileDescriptor[56]}
07-07 17:47:04.605  12696-12696/com.example.android.bluetoothchat D/AbsListView﹕ onDetachedFromWindow
07-07 17:47:04.605  12696-12696/com.example.android.bluetoothchat D/AbsListView﹕ onDetachedFromWindow
07-07 17:47:06.797  12696-12908/com.example.android.bluetoothchat D/BluetoothChatService﹕ start
07-07 17:47:06.797  12696-12908/com.example.android.bluetoothchat D/BluetoothChatService﹕ setState() 2 -> 1
// Unique UUID for this application
    private static final UUID MY_UUID_SECURE =
            UUID.fromString("00001101-0000-1000-8000-00805f9b34fb");
    private static final UUID MY_UUID_INSECURE =
            UUID.fromString("00001101-0000-1000-8000-00805f9b34fb");