블루투스 연결 기능을위한 클래스를 생성합니다. 연결 한 후에 장치를 연결할 위치에 도달 할 때까지 모든 것이 올바르게 작동하는 것처럼 보입니다. socket.connect를 호출하려고하면 IOException이 발생합니다. 여기안드로이드에서 소켓을 연결할 때 IOException이 발생합니다.
mSocket.connect();
를 호출 내가 무엇입니까 스택 트레이스 때
오류가 발생합니다.
나는이 유래 질문
java.io.IOException: read failed, socket might closed or timeout, read ret: -1 on Android 5.0.1 Lollipop versionBluetooth Connection failed "java.io.IOException: read failed, socket might closed or timeout, read ret: -1"하지만 여전히 내 문제를 해결하는 데 실패 살펴 보았다. 내 코드 전체를 확인해 볼 수 있습니다 HERE 뭔가를 놓친 것 같습니다.
여기에 스택 트레이스가 있습니다.
01-11 18:38:37.399 14502-14502/adc.com.samplebluetooth W/BluetoothAdapter: getBluetoothService() called with no BluetoothManagerCallback
01-11 18:38:37.409 14502-14502/adc.com.samplebluetooth D/BluetoothSocket: connect(), SocketState: INIT, mPfd: {ParcelFileDescriptor: FileDescriptor[60]}
01-11 18:38:38.629 14502-14502/adc.com.samplebluetooth W/System.err: java.io.IOException: read failed, socket might closed or timeout, read ret: -1
01-11 18:38:38.629 14502-14502/adc.com.samplebluetooth W/System.err: at android.bluetooth.BluetoothSocket.readAll(BluetoothSocket.java:505)
01-11 18:38:38.629 14502-14502/adc.com.samplebluetooth W/System.err: at android.bluetooth.BluetoothSocket.readInt(BluetoothSocket.java:516)
01-11 18:38:38.629 14502-14502/adc.com.samplebluetooth W/System.err: at android.bluetooth.BluetoothSocket.connect(BluetoothSocket.java:320)
01-11 18:38:38.639 14502-14502/adc.com.samplebluetooth W/System.err: at adc.com.samplebluetooth.Bluetooth.connectToPaired(Bluetooth.java:248)
01-11 18:38:38.639 14502-14502/adc.com.samplebluetooth W/System.err: at adc.com.samplebluetooth.MainActivity$OnClick.onClick(MainActivity.java:90)
01-11 18:38:38.639 14502-14502/adc.com.samplebluetooth W/System.err: at android.view.View.performClick(View.java:4443)
01-11 18:38:38.639 14502-14502/adc.com.samplebluetooth W/System.err: at android.view.View$PerformClick.run(View.java:18443)
01-11 18:38:38.639 14502-14502/adc.com.samplebluetooth W/System.err: at android.os.Handler.handleCallback(Handler.java:733)
01-11 18:38:38.639 14502-14502/adc.com.samplebluetooth W/System.err: at android.os.Handler.dispatchMessage(Handler.java:95)
01-11 18:38:38.639 14502-14502/adc.com.samplebluetooth W/System.err: at android.os.Looper.loop(Looper.java:136)
01-11 18:38:38.639 14502-14502/adc.com.samplebluetooth W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5017)
01-11 18:38:38.639 14502-14502/adc.com.samplebluetooth W/System.err: at java.lang.reflect.Method.invokeNative(Native Method)
01-11 18:38:38.639 14502-14502/adc.com.samplebluetooth W/System.err: at java.lang.reflect.Method.invoke(Method.java:515)
01-11 18:38:38.639 14502-14502/adc.com.samplebluetooth W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
01-11 18:38:38.639 14502-14502/adc.com.samplebluetooth W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
01-11 18:38:38.639 14502-14502/adc.com.samplebluetooth W/System.err: at dalvik.system.NativeStart.main(Native Method)