在没有 BluetoothManagerCallback 的情况下调用 getBluetoothService() [英] getBluetoothService() called with no BluetoothManagerCallback
问题描述
我是安卓开发的新手.我正在编写一个应用程序,它从笔记本电脑的蓝牙终端接收字符串.在打开连接时,执行以下行时出现错误连接拒绝.
I am new to android development. I am writing an app which receives string from the bluetooth terminal of laptop. while opening a connection i am getting an error Connection Refused when the below line gets executed.
socket.connect();
我试图检查 connect 方法中发生了什么.在这里,我发现 Android Studio 给了我类似的问题.
I tried to check what happens in connect method. Here I found Android Studio giving me issues like.
无法访问 android.bluetooth.BluetoothSocket.SocketState.
Cannot access android.bluetooth.BluetoothSocket.SocketState.
无法解析方法 createSocketChannel.
Cannot resolve method createSocketChannel.
无法解析符号 IBluetooth.
Cannot resolve Symbol IBluetooth.
我的开发环境有问题吗?以下是例外.
Does my development environment have a problem? below is the 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.
推荐答案
运行时错误明确说明问题:
The run-time error explictly states the problem:
getBluetoothService() 在没有 BluetoothManagerCallback 的情况下被调用
getBluetoothService() called with no BluetoothManagerCallback
所以你需要提供一个BluetoothManagerCallback
这篇关于在没有 BluetoothManagerCallback 的情况下调用 getBluetoothService()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!