When I said "fork" I didn't mean "fork" in the sense of "create a new process", but rather in the sense of "copy the existing code to a new class and change it". If you look at the implementation of IOIOActivity, you'll notice that it calls start()/stop() etc. at different times in its lifecycle, causing the IOIO connection to get created / destroyed respectively. You can change that so that these methods are invoked in response to different events. However, keep in mind that Android makes no guarantees about when it is going to pause()/stop()/destroy() your app, so if you want 100% guarantee that the IOIO connection will be kept alive you need to either prevent the phone from sleeping or use IOIOService. There are standard mechanisms to communicate between the app and the service. One simple thing you can do is use those mechanism to just provide the IOIO interface to the Activity as soon as one is available.
On Sun, Mar 13, 2016 at 4:33 AM, Ilan Tal <[email protected]> wrote: > Thanks for the advice Ytai. I'm still not out of the woods though. > My first attempt was to try IOIOService. That is a bit too powerful as > MainActivity has some graphic elements that I need to communicate with. > I ran into real trouble with runOnUiThread since in the IOIOService I no > longer have the Main Activity class. That got a finish command. > > Your second idea of Fork IOIOActivity looks more promising but since I'm > still new to the android world I don't know how to do the fork. > I understand that it is basically a new thread which perhaps I can send > the MainActivity object, so that I can do a runOnUiThread on the main > activity object. > The nuts and bolts of exactly how to do this are unclear to me. I tried to > google around for some sort of example or tutorial but I must be missing > the appropriate key words. > > It also isn't clear to me why in the original application the IOIO board > was disconnected when my application itself kept running. I have a timer in > my application and I can see that it keeps progressing even when the IOIO > board has been disconnected. It is clear to me why the application would > continue but the connection to the IOIO board wouldn't continue. > > In any case, presumably if I fork off my own class which has IOIOActivity, > then that class wouldn't die when the android display shut down. Exactly > the correct commands to create and control such a class are not clear to > me. On the other hand I do want my main activity, or something else, to > have control over what the IOIO board is doing. > > If you can point me in the right direction to get my hands on some sample > code, I would greatly appreciate it. > > Thanks, > Ilan > > -- > 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 https://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 https://groups.google.com/group/ioio-users. For more options, visit https://groups.google.com/d/optout.
