getBluetoothService () ohne BluetoothManagerCallback aufgerufen

Ich bin neu in der Android-Entwicklung. Ich schreibe eine App, die Zeichenfolge vom Bluetooth-Terminal des Laptops empfängt. Beim Öffnen einer Verbindung wird eine Fehlermeldung angezeigt. Verbindung abgelehnt, wenn die folgende Zeile ausgeführt wird.

socket.connect();

Ich habe versucht zu überprüfen, was in der connect-Methode passiert. Hier fand ich Android Studio, das mir Probleme wie.

Kann nicht auf android.bluetooth.BluetoothSocket.SocketState zugreifen.

Kann die Methode createSocketChannel nicht auflösen.

Kann Symbol IBluetooth nicht auflösen.

Hat meine Entwicklungsumgebung ein Problem? unten ist die Ausnahme.

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.

Antworten auf die Frage(2)

Ihre Antwort auf die Frage