android 连接已配对蓝牙耳机,连接/配对蓝牙耳机和Android 港控/mmm° 2022-10-16 07:41 259阅读 0赞 我想创建一个简单的程序,扫描蓝牙耳机(我正在测试一个PS3耳机),然后连接到它。我正在使用bluetooth chat program example中的代码。但是我无法将它连接到任何东西。当它到达connect()时它给我一个I/O异常。连接/配对蓝牙耳机和Android private static final UUID MY\_UUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB"); 此线程在尝试与设备建立传出连接时运行。它贯穿始终;连接成功或失败。 private class ConnectThread extends Thread \{ private final BluetoothSocket mmSocket; private final BluetoothDevice mmDevice; public ConnectThread(BluetoothDevice device) \{ mmDevice = device; BluetoothSocket tmp = null; // Get a BluetoothSocket for a connection with the given BluetoothDevice try \{ tmp = device.createRfcommSocketToServiceRecord(MY\_UUID); \} catch (IOException e) \{ Log.e(TAG, "create() failed", e); \} if (tmp == null)\{ Log.i(TAG, "tmp is NULL"); \} mmSocket = tmp; \} public void run() \{ Log.i(TAG, "BEGIN mConnectThread"); setName("ConnectThread"); // Always cancel discovery because it will slow down a connection mAdapter.cancelDiscovery(); Log.i(TAG, "discovery is cancelled"); // Make a connection to the BluetoothSocket try \{ // This is a blocking call and will only return on a successful connection or an exception mmSocket.connect(); //Doesn't like something here??? \} catch (IOException e) \{ Log.e(TAG, "IO error, ", e); connectionFailed(); // Close the socket try \{ mmSocket.close(); \} catch (IOException e2) \{ Log.e(TAG, "unable to close() socket during connection failure", e2); \} // Start the service over to restart listening mode newTBluetoothService.this.start(); return; \} // Reset the ConnectThread because we're done synchronized (newBluetoothService.this) \{ mConnectThread = null; \} // Start the connected thread connected(mmSocket, mmDevice); \} public void cancel() \{ try \{ mmSocket.close(); \} catch (IOException e) \{ Log.e(TAG, "close() of connect socket failed", e); \} \} \} 这里是logcat的: 10-13 16:07:45.544: ERROR/BluetoothService.cpp(1259): stopDiscoveryNative: D-Bus error in StopDiscovery: org.bluez.Error.Failed (Invalid discovery session) 10-13 16:07:45.544: DEBUG/newBluetoothService(2821): connect to: 00:22:A6:07:12:2B 10-13 16:07:45.544: DEBUG/newBluetoothService(2821): setState() 0 -> 2 10-13 16:07:45.552: INFO/newBluetoothService(2821): BEGIN mConnectThread 10-13 16:07:45.567: ERROR/BluetoothService.cpp(1259): stopDiscoveryNative: D-Bus error in StopDiscovery: org.bluez.Error.Failed (Invalid discovery session) 10-13 16:07:45.567: INFO/newBluetoothService(2821): discovery is cancelled 10-13 16:07:45.575: ERROR/BluetoothEventLoop.cpp(1259): onCreateDeviceResult: D-Bus error: org.bluez.Error.AlreadyExists (Device already exists) 10-13 16:07:45.583: INFO/BluetoothNew(2821): MESSAGE\_STATE\_CHANGE: 2 10-13 16:07:46.700: ERROR/BluetoothEventLoop.cpp(1259): event\_filter: Received signal org.bluez.Device:PropertyChanged from /org/bluez/2872/hci0/dev\_00\_22\_A6\_07\_12\_2B 10-13 16:07:47.036: DEBUG/BluetoothService(1259): updateDeviceServiceChannelCache(00:22:A6:07:12:2B) 10-13 16:07:47.059: DEBUG/BluetoothService(1259): uuid(system): 0000111e-0000-1000-8000-00805f9b34fb 1 10-13 16:07:47.067: DEBUG/BluetoothService(1259): uuid(system): 00001108-0000-1000-8000-00805f9b34fb 2 10-13 16:07:47.075: VERBOSE/BluetoothEventRedirector(1786): Received android.bleutooth.device.action.UUID 10-13 16:07:47.075: DEBUG/BluetoothService(1259): Cleaning up failed UUID channel lookup: 00:22:A6:07:12:2B 00001101-0000-1000-8000-00805f9b34fb 10-13 16:07:47.083: ERROR/newBluetoothService(2821): IO error, 10-13 16:07:47.083: ERROR/newBluetoothService(2821): java.io.IOException: Service discovery failed 10-13 16:07:47.083: ERROR/newBluetoothService(2821): at android.bluetooth.BluetoothSocket$SdpHelper.doSdp(BluetoothSocket.java:377) 10-13 16:07:47.083: ERROR/newBluetoothService(2821): at android.bluetooth.BluetoothSocket.connect(BluetoothSocket.java:201) 10-13 16:07:47.083: ERROR/newBluetoothService(2821): at com.nmtransfer.bluetooth.newBluetoothService$ConnectThread.run(newBluetoothService.java:347) 10-13 16:07:47.083: INFO/newBluetoothService(2821): Connection Failed 10-13 16:07:47.083: DEBUG/newBluetoothService(2821): setState() 2 -> 1 10-13 16:07:47.083: DEBUG/newBluetoothService(2821): start 10-13 16:07:47.083: INFO/BluetoothNew(2821): MESSAGE\_STATE\_CHANGE: 1 10-13 16:07:47.098: DEBUG/BluetoothService(1259): new handle 1000d 10-13 16:07:47.106: DEBUG/newBluetoothService(2821): setState() 1 -> 1 10-13 16:07:47.106: DEBUG/newBluetoothService(2821): BEGIN mAcceptThreadThread\[Thread- 13,5,main\] 10-13 16:07:47.114: INFO/BluetoothNew(2821): MESSAGE\_STATE\_CHANGE: 1 10-13 16:07:51.036: ERROR/BluetoothEventLoop.cpp(1259): event\_filter: Received signal org.bluez.Device:PropertyChanged from /org/bluez/2872/hci0/dev\_00\_22\_A6\_07\_12\_2B 10-13 16:07:53.583: VERBOSE/BluetoothEventRedirector(1786): Received android.bleutooth.device.action.UUID 任何帮助深表感谢。 谢谢 克里斯 \+0 我正在使用2.2更新版和PS3蓝牙耳机在Droid X上进行测试。它正在配对,但不会连接。当我进入蓝牙设置时,我可以手动连接耳机。 – 2010-10-14 17:02:27
相关 Android Bluetooth蓝牙开发:Bluetooth蓝牙设备配对Paired Bluetooth Devices(2) Android Bluetooth蓝牙开发:Bluetooth蓝牙设备配对Paired Bluetooth Devices(2) 不同的Bluetooth进行配 小鱼儿/ 2024年02月17日 16:52/ 0 赞/ 20 阅读
相关 archlinux 蓝牙耳机没有声音 前提 蓝牙已开,并且连接成功,但是蓝牙耳机没有声音。 安装 pacman -S pulseaudio-bluetooth pulsemixer 切 今天药忘吃喽~/ 2023年10月10日 10:06/ 0 赞/ 27 阅读
相关 实现链接蓝牙耳机_我,从未见过,如此超长续航的蓝牙耳机 蓝牙耳机,我想大家都接触过,具体实现方式在这里就不用多做介绍了。蓝牙耳机有多少类型呢?其实这个问题可以根据佩戴方式区分,比如头戴式,入耳式,颈挂式,双耳独立式和骨传导式,耳塞式 叁歲伎倆/ 2023年01月07日 02:30/ 0 赞/ 203 阅读
相关 android 连接已配对蓝牙耳机,连接/配对蓝牙耳机和Android 我想创建一个简单的程序,扫描蓝牙耳机(我正在测试一个PS3耳机),然后连接到它。我正在使用bluetooth chat program example中的代码。但是我无法将它连 港控/mmm°/ 2022年10月16日 07:41/ 0 赞/ 260 阅读
相关 两个HC05蓝牙配对 购买蓝牙HC05模块的链接如下: [https://item.taobao.com/item.htm?spm=a1z09.2.0.0.5dda2e8dcmktTe&id=58 约定不等于承诺〃/ 2022年09月04日 03:51/ 0 赞/ 207 阅读
相关 Android 蓝牙开发——获取已配对蓝牙并显示 activity\_blue\_paired.xml布:里面有一个列表,用于显示所有已配对的设备 <?xml version="1.0" encoding="utf- 深碍√TFBOYSˉ_/ 2022年06月08日 13:29/ 0 赞/ 861 阅读
相关 Android 蓝牙搜索,配对,连接发送数据 首先需要在清单配置里面添加两个权限: <uses-permission android:name="android.permission.BLUETOOTH" /> 小灰灰/ 2022年05月24日 11:52/ 0 赞/ 237 阅读
相关 Android实现蓝牙耳机连接 > 代码地址如下: > [http://www.demodashi.com/demo/13259.html][http_www.demodashi.com_demo_132 矫情吗;*/ 2022年05月12日 08:26/ 0 赞/ 587 阅读
相关 降噪蓝牙耳机_降噪耳机如何工作? ![降噪蓝牙耳机][00a59c710c81fa4170d70efbeb4e1861.png] 降噪蓝牙耳机 ![banner][] Passive noise redu ゝ一世哀愁。/ 2021年07月26日 16:47/ 0 赞/ 553 阅读
还没有评论,来说两句吧...