Ah OK. I've fgound that indeed, 'Connect' is being called twice.
This is because 'Connect' is called from within DiscoveryFinished.
I can see that I am getting two DiscoveryFinished events, even after cancelling discovery. The second one occurs the moment I press the 'Pair? - OK' button and my activity is resumed (after being paused buy the system 'OK to pair?' dialog).
** Activity (main) Pause, UserClosed = false **
** Activity (settings) Create, isFirst = true **
** Activity (settings) Resume **
stop listening
*13:55:31:866::I:Units_Comms:stop listening
discovery started
Spiro_001003
8:80:39:F0
1:22
discovery cancelled
:08:61:E2:46:CA:A9
0:03:4B:49:6A:2E
*13:55:45:621::I:Units_Comms:Spiro_001003
8:80:39:F0
1:22
*13:55:46:078::I:Units_Comms::08:61:E2:46:CA:A9
*13:55:46:101::I:Units_Comms:
0:03:4B:49:6A:2E
entering DISCOVERY FINISHED
Unit is not paired
connect direct to D8:80:39:F0
1:22
*13:55:46:203::I:Units_Comms:connect direct to D8:80:39:F0
1:22
** Activity (settings) Pause, UserClosed = false **
*** Service (btpair) Create ***
** Service (btpair) Start **
** Service (btpair) Start **
Unit is not paired
** Activity (settings) Resume **
entering DISCOVERY FINISHED
Unit is not paired
connect direct to D8:80:39:F0
1:22
connected: false
let's hope another connection follows this one
*13:55:59:152::I:Units_Comms:connect direct to D8:80:39:F0
1:22
*13:55:59:232::I:Units_Comms:connected: false
connected: true
loc3 java.io.IOException: bt socket closed, read return: -1
admin statechange. old = STATE_ON new = STATE_TURNING_OFF
*13:55:59:274::I:Units_Comms:connected: true
*13:55:59:503::I:Units_Comms:admin statechange. old = STATE_ON new = STATE_TURNING_OFF
admin statechange. old = STATE_TURNING_OFF new = STATE_OFF
admin statechange. old = STATE_OFF new = STATE_TURNING_ON
admin statechange. old = STATE_TURNING_ON new = STATE_ON
StartListen2
listening
*13:55:59:573::I:Units_Comms:admin statechange. old = STATE_TURNING_OFF new = STATE_OFF
*13:55:59:593::I:Units_Comms:admin statechange. old = STATE_OFF new = STATE_TURNING_ON
*13:55:59:768::I:Units_Comms:admin statechange. old = STATE_TURNING_ON new = STATE_ON
*13:55:59:772::I:Units_Comms:listening
stop listening
Is that expected? I am definitely only starting one discovery and cancelling it.