gpt4 book ai didi

android - 没有调用 BluetoothManagerCallback 的 getBluetoothService()

转载 作者:太空宇宙 更新时间:2023-11-03 11:26:50 32 4
gpt4 key购买 nike

我是安卓开发的新手。我正在编写一个从笔记本电脑的蓝牙终端接收字符串的应用程序。在打开连接时,当执行以下行时出现连接被拒绝的错误。

socket.connect();

我试图检查连接方法中发生了什么。在这里,我发现 Android Studio 给我类似的问题。

  1. Cannot access android.bluetooth.BluetoothSocket.SocketState.

  2. Cannot resolve method createSocketChannel.

  3. Cannot resolve Symbol IBluetooth.

我的开发环境有问题吗?以下是异常(exception)情况。

02-15 23:19:54.112 18794-18794/poc.tusharimaging.com.bluetooth_poc W/BluetoothAdapter: getBluetoothService() called with no BluetoothManagerCallback
02-15 23:20:33.754 18794-18794/poc.tusharimaging.com.bluetooth_poc W/System.err: java.io.IOException: read failed, socket might closed or timeout, read ret: -1
02-15 23:20:33.773 18794-18794/poc.tusharimaging.com.bluetooth_poc W/System.err: at android.bluetooth.BluetoothSocket.readAll(BluetoothSocket.java:684)
02-15 23:20:33.785 18794-18794/poc.tusharimaging.com.bluetooth_poc W/System.err: at android.bluetooth.BluetoothSocket.waitSocketSignal(BluetoothSocket.java:643)
02-15 23:20:33.795 18794-18794/poc.tusharimaging.com.bluetooth_poc W/System.err: at android.bluetooth.BluetoothSocket.connect(BluetoothSocket.java:377)
02-15 23:20:33.806 18794-18794/poc.tusharimaging.com.bluetooth_poc W/System.err: at poc.tusharimaging.com.bluetooth_poc.MainActivity.openBT(MainActivity.java:145)
02-15 23:20:33.815 18794-18794/poc.tusharimaging.com.bluetooth_poc W/System.err: at poc.tusharimaging.com.bluetooth_poc.MainActivity$1.onClick(MainActivity.java:75)
02-15 23:20:33.823 18794-18794/poc.tusharimaging.com.bluetooth_poc W/System.err: at android.view.View.performClick(View.java:5204)
02-15 23:20:33.830 18794-18794/poc.tusharimaging.com.bluetooth_poc W/System.err: at android.view.View$PerformClick.run(View.java:21153)
02-15 23:20:33.837 18794-18794/poc.tusharimaging.com.bluetooth_poc W/System.err: at android.os.Handler.handleCallback(Handler.java:739)
02-15 23:20:33.843 18794-18794/poc.tusharimaging.com.bluetooth_poc W/System.err: at android.os.Handler.dispatchMessage(Handler.java:95)
02-15 23:20:33.850 18794-18794/poc.tusharimaging.com.bluetooth_poc W/System.err: at android.os.Looper.loop(Looper.java:148)
02-15 23:20:33.857 18794-18794/poc.tusharimaging.com.bluetooth_poc W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5417)
02-15 23:20:33.863 18794-18794/poc.tusharimaging.com.bluetooth_poc W/System.err: at java.lang.reflect.Method.invoke(Native Method)
02-15 23:20:33.871 18794-18794/poc.tusharimaging.com.bluetooth_poc W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
02-15 23:20:33.878 18794-18794/poc.tusharimaging.com.bluetooth_poc W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
02-15 23:25:15.354 18794-18794/poc.tusharimaging.com.bluetooth_poc I/Choreographer: Skipped 18837 frames! The application may be doing too much work on its main thread.
02-15 23:25:15.801 18794-18991/poc.tusharimaging.com.bluetooth_poc D/OpenGLRenderer: endAllStagingAnimators on 0x7f9ec3c000 (RippleDrawable) with handle 0x7f9dd29f60
02-15 23:25:16.532 18794-18794/poc.tusharimaging.com.bluetooth_poc I/Choreographer: Skipped 55 frames! The application may be doing too much work on its main thread.

最佳答案

运行时错误明确说明了问题:

getBluetoothService() called with no BluetoothManagerCallback

所以你需要提供一个BluetoothManagerCallback

关于android - 没有调用 BluetoothManagerCallback 的 getBluetoothService(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35397159/

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