I'm getting an IOexception when setting bluetooth to listen on my android 4.4.4 tablet.
When my app starts, bluetooth admin gets enabled, and Listen is called only when the Admin_StateChanged function has a new state of STATE_ON.
when I start listening at that point, I get:
** Activity (main) Resume **
** Service (unit_comms) Create **
** Service (unit_comms) Start **
admin statechange. old = STATE_ON new = STATE_TURNING_OFF
admin statechange. old = STATE_TURNING_OFF new = STATE_ON
StartToListen
Error occurred on line: 0 (Unit_Comms)
java.io.IOException: Error: -1
at android.bluetooth.BluetoothAdapter.createNewRfcommSocketAndRecord(BluetoothAdapter.java:1240)
at android.bluetooth.BluetoothAdapter.listenUsingRfcommWithServiceRecord(BluetoothAdapter.java:1156)
at anywheresoftware.b4a.objects.Serial.Listen2(Serial.java:233)
at anywheresoftware.b4a.objects.Serial.Listen(Serial.java:221)
at com.medchipsolutions.spiroconnectmobile.unit_comms._startlistening(unit_comms.java:316)
at com.medchipsolutions.spiroconnectmobile.unit_comms._admin_statechanged(unit_comms.java:692)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:708)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:337)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:247)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:153)
at anywheresoftware.b4a.objects.Serial$BluetoothAdmin$1$1.run(Serial.java:343)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
** Activity (main) Pause, UserClosed = true **
** Service (unit_comms) Destroy **
Any ideas? Or how can I get more info on this error?
When my app starts, bluetooth admin gets enabled, and Listen is called only when the Admin_StateChanged function has a new state of STATE_ON.
when I start listening at that point, I get:
** Activity (main) Resume **
** Service (unit_comms) Create **
** Service (unit_comms) Start **
admin statechange. old = STATE_ON new = STATE_TURNING_OFF
admin statechange. old = STATE_TURNING_OFF new = STATE_ON
StartToListen
Error occurred on line: 0 (Unit_Comms)
java.io.IOException: Error: -1
at android.bluetooth.BluetoothAdapter.createNewRfcommSocketAndRecord(BluetoothAdapter.java:1240)
at android.bluetooth.BluetoothAdapter.listenUsingRfcommWithServiceRecord(BluetoothAdapter.java:1156)
at anywheresoftware.b4a.objects.Serial.Listen2(Serial.java:233)
at anywheresoftware.b4a.objects.Serial.Listen(Serial.java:221)
at com.medchipsolutions.spiroconnectmobile.unit_comms._startlistening(unit_comms.java:316)
at com.medchipsolutions.spiroconnectmobile.unit_comms._admin_statechanged(unit_comms.java:692)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:708)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:337)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:247)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:153)
at anywheresoftware.b4a.objects.Serial$BluetoothAdmin$1$1.run(Serial.java:343)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
** Activity (main) Pause, UserClosed = true **
** Service (unit_comms) Destroy **
Any ideas? Or how can I get more info on this error?