Hm, I'm still not figuring out the cause of the issue. I'd assume that 
helper_.start() in the IOIOActivity onStart() should get the Bluetooth 
connection back, but it doesn't. Whether the main app gets 
destroyed/created seems to be an arbitrary thing that the Android OS takes 
care of, perhaps to clear up memory. I'm working around the problem by 
forcing the app to quit and restart after the end of a scan(), and keeping 
the relevant state by passing variables through an Intent. This is the 
quickest solution for now and works fine for me, but I will try to do some 
more debugging later and post if I find a solution.

On Thursday, May 21, 2015 at 10:30:40 AM UTC-7, Ytai wrote:
>
> The method that emits the "main activity restarting": what's actually 
> happening there? Is it possible that some event that needs to propagate to 
> the IOIO framework doesn't make it through? Looks like the 
> destroy()/create() sequence is what makes things work. Can you debug a 
> little and figure out what is it that they do that makes a difference?
>
> On Wed, May 20, 2015 at 5:34 PM, hwut <[email protected] <javascript:>> 
> wrote:
>
>> Sorry, I see what you mean about the IOIOLib logs now. I'm using the most 
>> recent version, version 5, and a bluetooth connection between the Android 
>> and IOIO.
>>
>> Here is the log when I first open the app. All "blar" tags are my own 
>> generated tags.
>>
>> 05-20 17:27:21.921: D/IOIOConnectionRegistry(23052): Successfully added 
>> bootstrap class: ioio.lib.impl.SocketIOIOConnectionBootstrap
>> 05-20 17:27:21.921: D/IOIOConnectionRegistry(23052): Bootstrap class not 
>> found: ioio.lib.android.accessory.AccessoryConnectionBootstrap. Not adding.
>> 05-20 17:27:21.931: D/IOIOConnectionRegistry(23052): Successfully added 
>> bootstrap class: ioio.lib.android.bluetooth.BluetoothIOIOConnectionBootstrap
>> 05-20 17:27:21.931: D/IOIOConnectionRegistry(23052): Bootstrap class not 
>> found: ioio.lib.android.device.DeviceConnectionBootstrap. Not adding.
>> 05-20 17:27:21.951: I/blar(23052): main activity being created
>> 05-20 17:27:22.021: I/blar(23052): AndroidApplicationHelper create()
>> 05-20 17:27:22.021: I/blar(23052): AndroidIOIOConnectionManager create()
>> 05-20 17:27:22.031: I/blar(23052): main activity starting
>> 05-20 17:27:22.031: I/blar(23052): AndroidApplicationHelper start()
>> 05-20 17:27:22.031: I/blar(23052): AndroidIOIOConnectionManager start()
>> 05-20 17:27:22.041: I/blar(23052): main activity resuming
>> 05-20 17:27:22.051: D/IOIOImpl(23052): Waiting for IOIO connection
>> 05-20 17:27:22.051: V/IOIOImpl(23052): Waiting for underlying connection
>> 05-20 17:27:22.071: V/BluetoothIOIOConnection(23052): Attempting to 
>> connect to Bluetooth device: IOIO (5C:82)
>> 05-20 17:27:23.131: V/BluetoothIOIOConnection(23052): Established 
>> connection to device IOIO (5C:82) address: 00:1B:DC:06:5C:82
>> 05-20 17:27:23.131: V/IOIOImpl(23052): Waiting for handshake
>> 05-20 17:27:23.131: V/IOIOImpl(23052): Querying for required interface ID
>> 05-20 17:27:23.141: V/IOIOImpl(23052): Required interface ID is supported
>> 05-20 17:27:23.141: I/IOIOImpl(23052): IOIO connection established
>>
>> This is what happens when scan() is called, and reconnection of the IOIO 
>> is successful. The main activity had been destroyed and recreated.
>>
>> 05-20 17:27:27.671: I/blar(23052): scan() called
>> 05-20 17:27:27.701: I/blar(23052): main activity pausing
>> 05-20 17:27:28.531: I/blar(23052): main activity stopping
>> 05-20 17:27:28.531: I/blar(23052): AndroidApplicationHelper stop()
>> 05-20 17:27:28.531: D/IOIOImpl(23052): Client requested disconnect.
>> 05-20 17:27:28.531: V/BluetoothIOIOConnection(23052): Client initiated 
>> disconnect
>> 05-20 17:27:28.531: D/IOIOImpl(23052): Client requested disconnect.
>> 05-20 17:27:28.531: I/IOIOProtocol(23052): IOIO disconnected
>> 05-20 17:27:28.531: I/blar(23052): IOIO_thread disconnected
>> 05-20 17:27:28.541: D/IOIOBaseApplicationHelper(23052): IOIOThread is 
>> exiting
>> 05-20 17:27:28.541: I/blar(23052): AndroidIOIOConnectionManager stop()
>> 05-20 17:27:34.171: I/blar(23052): main activity being destroyed
>> 05-20 17:27:34.171: I/blar(23052): AndroidApplicationHelper destroy()
>> 05-20 17:27:34.171: I/blar(23052): AndroidIOIOConnectionManager destroy()
>> 05-20 17:27:34.191: I/blar(23052): main activity being created
>> 05-20 17:27:34.221: I/blar(23052): AndroidApplicationHelper create()
>> 05-20 17:27:34.221: I/blar(23052): AndroidIOIOConnectionManager create()
>> 05-20 17:27:34.231: I/blar(23052): main activity starting
>> 05-20 17:27:34.231: I/blar(23052): AndroidApplicationHelper start()
>> 05-20 17:27:34.231: I/blar(23052): AndroidIOIOConnectionManager start()
>> 05-20 17:27:34.251: D/IOIOImpl(23052): Waiting for IOIO connection
>> 05-20 17:27:34.251: V/IOIOImpl(23052): Waiting for underlying connection
>> 05-20 17:27:34.251: V/BluetoothIOIOConnection(23052): Attempting to 
>> connect to Bluetooth device: IOIO (5C:82)
>> 05-20 17:27:34.271: I/blar(23052): main activity resuming
>> 05-20 17:27:34.521: V/BluetoothIOIOConnection(23052): Established 
>> connection to device IOIO (5C:82) address: 00:1B:DC:06:5C:82
>> 05-20 17:27:34.521: V/IOIOImpl(23052): Waiting for handshake
>> 05-20 17:27:34.521: V/IOIOImpl(23052): Querying for required interface ID
>> 05-20 17:27:34.531: V/IOIOImpl(23052): Required interface ID is supported
>> 05-20 17:27:34.541: I/IOIOImpl(23052): IOIO connection established
>>
>> This is what happens when the reconnection doesn't work:
>>
>> 05-20 17:27:47.001: I/blar(23052): scan() called
>> 05-20 17:27:47.031: I/blar(23052): main activity pausing
>> 05-20 17:27:48.811: I/blar(23052): main activity stopping
>> 05-20 17:27:48.811: I/blar(23052): AndroidApplicationHelper stop()
>> 05-20 17:27:48.811: D/IOIOImpl(23052): Client requested disconnect.
>> 05-20 17:27:48.811: V/BluetoothIOIOConnection(23052): Client initiated 
>> disconnect
>> 05-20 17:27:48.821: I/IOIOProtocol(23052): IOIO disconnected
>> 05-20 17:27:48.821: I/blar(23052): IOIO_thread disconnected
>> 05-20 17:27:48.821: D/IOIOBaseApplicationHelper(23052): IOIOThread is 
>> exiting
>> 05-20 17:27:48.821: I/blar(23052): AndroidIOIOConnectionManager stop()
>> 05-20 17:27:53.021: I/blar(23052): main activity restarting
>> 05-20 17:27:53.021: I/blar(23052): main activity starting
>> 05-20 17:27:53.021: I/blar(23052): AndroidApplicationHelper start()
>> 05-20 17:27:53.021: I/blar(23052): AndroidIOIOConnectionManager start()
>> 05-20 17:27:53.031: I/blar(23052): main activity resuming
>>
>>
>> On Tuesday, May 19, 2015 at 3:01:29 PM UTC-7, Ytai wrote:
>>>
>>> You seem to have omitted the logs generated by IOIOLib itself. Can you 
>>> include them? Which version of the library is this? What type of connection 
>>> are you using between the Android and IOIO?
>>> On May 19, 2015 2:51 PM, "hwut" <[email protected]> wrote:
>>>
>>>> Sure, here is a log of the case that causes the problem:
>>>>
>>>> 05-19 14:15:08.018: I/abr.main(17259): scan() called
>>>> 05-19 14:15:08.038: I/abr.main(17259): main activity pausing
>>>> 05-19 14:15:09.828: I/abr.main(17259): main activity stopping
>>>> 05-19 14:15:09.828: I/AndroidApplicationHelper(17259): 
>>>> AndroidApplicationHelper stop()
>>>> 05-19 14:15:09.838: I/IOIO_thread(17259): IOIO_thread disconnected
>>>> 05-19 14:15:09.838: I/AndroidIOIOConnectionManager(17259): 
>>>> AndroidIOIOConnectionManager stop()
>>>> 05-19 14:15:14.068: I/abr.main(17259): main activity restarting
>>>> 05-19 14:15:14.068: I/abr.main(17259): main activity starting
>>>> 05-19 14:15:14.068: I/AndroidApplicationHelper(17259): 
>>>> AndroidApplicationHelper start()
>>>> 05-19 14:15:14.068: I/AndroidIOIOConnectionManager(17259): 
>>>> AndroidIOIOConnectionManager start()
>>>> 05-19 14:15:14.068: I/abr.main(17259): main activity resuming
>>>>
>>>> Occasionally, when starting the new activity, the main activity will be 
>>>> destroyed. In this case the IOIO connection does come back.
>>>>
>>>> 05-19 14:45:19.398: I/abr.main(2984): scan() called
>>>> 05-19 14:45:19.438: I/abr.main(2984): main activity pausing
>>>> 05-19 14:45:20.318: I/abr.main(2984): main activity stopping
>>>> 05-19 14:45:20.318: I/AndroidApplicationHelper(2984): 
>>>> AndroidApplicationHelper stop()
>>>> 05-19 14:45:20.328: I/IOIO_thread(2984): IOIO_thread disconnected
>>>> 05-19 14:45:20.328: I/AndroidIOIOConnectionManager(2984): 
>>>> AndroidIOIOConnectionManager stop()
>>>> 05-19 14:45:25.868: I/abr.main(2984): main activity being destroyed
>>>> 05-19 14:45:25.868: I/AndroidApplicationHelper(2984): 
>>>> AndroidApplicationHelper destroy()
>>>> 05-19 14:45:25.868: I/AndroidIOIOConnectionManager(2984): 
>>>> AndroidIOIOConnectionManager destroy()
>>>> 05-19 14:45:25.898: I/abr.main(2984): main activity being created
>>>> 05-19 14:45:25.958: I/AndroidApplicationHelper(2984): 
>>>> AndroidApplicationHelper create()
>>>> 05-19 14:45:25.958: I/AndroidIOIOConnectionManager(2984): 
>>>> AndroidIOIOConnectionManager create()
>>>> 05-19 14:45:25.968: I/abr.main(2984): main activity starting
>>>> 05-19 14:45:25.968: I/AndroidApplicationHelper(2984): 
>>>> AndroidApplicationHelper start()
>>>> 05-19 14:45:25.968: I/AndroidIOIOConnectionManager(2984): 
>>>> AndroidIOIOConnectionManager start()
>>>> 05-19 14:45:25.978: I/abr.main(2984): main activity resuming
>>>> 05-19 14:45:25.988: I/abr.main(2984): main activity pausing
>>>> 05-19 14:45:26.018: I/abr.main(2984): main activity resuming
>>>>
>>>> On Monday, May 18, 2015 at 9:18:12 PM UTC-7, Ytai wrote:
>>>>>
>>>>> Can you add some logs and figure out the exact sequence of lifecycle 
>>>>> calls (e.g. onStart(), onStop(), etc.) in your scenario? Also include the 
>>>>> relevant IOIO logs so we can see whether a connection is closed properly 
>>>>> before switching.
>>>>>
>>>>> On Mon, May 18, 2015 at 3:15 PM, Tiffany Hwu <[email protected]> wrote:
>>>>>
>>>>>> I have a main activity that extends IOIOActivity. Within this main 
>>>>>> activity I have function called scan(), which calls 
>>>>>> startActivityForResult() to open up a new activity to scan a QR code 
>>>>>> using 
>>>>>> the Android phone. The usual life cycle for main activity in this case 
>>>>>> is 
>>>>>> to pause, stop, let the QR activity scan, start, then resume. 
>>>>>> Accordingly, 
>>>>>> I think the  
>>>>>>
>>>>>> IOIOAndroidApplicationHelper should reestablish the IOIO connection 
>>>>>> at the start stage. However, this doesn't happen and the IOIO connection 
>>>>>> is 
>>>>>> gone when the main activity resumes. Any ideas on why this is happening? 
>>>>>> I 
>>>>>> can post some code if more clarity is needed. Thanks!
>>>>>>
>>>>>> -- 
>>>>>> You received this message because you are subscribed to the Google 
>>>>>> Groups "ioio-users" group.
>>>>>> To unsubscribe from this group and stop receiving emails from it, 
>>>>>> send an email to [email protected].
>>>>>> To post to this group, send email to [email protected].
>>>>>> Visit this group at http://groups.google.com/group/ioio-users.
>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>
>>>>>
>>>>>  -- 
>>>> You received this message because you are subscribed to the Google 
>>>> Groups "ioio-users" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>> an email to [email protected].
>>>> To post to this group, send email to [email protected].
>>>> Visit this group at http://groups.google.com/group/ioio-users.
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "ioio-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> Visit this group at http://groups.google.com/group/ioio-users.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"ioio-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/ioio-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to