Page 1 of 1

Android externals getEngineApi issue

Posted: Wed Jul 09, 2014 4:42 am
by monte
I've been banging my head against an issue with android externals where if the user used the back button to kill the app I couldn't instantiate a control on the next load of the app. I know android likes to keep variable instances hanging around and I thought the problem was with my external but after trying everything I could think of nothing worked. Then I thought... why not take a look to see if the issue is in Support.java. Lo and behold there's:

Code: Select all


private static EngineApi s_engine_api = null;

private static EngineApi getEngineApi()
{
    if (s_engine_api == null)
         s_engine_api = __InterfaceQueryEngine();
    return s_engine_api;
}
Now there's two ways around this. Either just call __InterfaceQueryEngine() every time or work out a way to nullify s_engine_api when the app is being killed. What's your preference? For the time being I'm just commenting out if(s_engine_api == null).

Re: Android externals getEngineApi issue

Posted: Wed Jul 16, 2014 9:07 am
by LCMark
@monte: I think removing the static EngineApi var is the best we can do at the moment... The LC class is per external at the moment and the static vars in it will be re-initialized only on class-load. As Dalvik doesn't reload anything between an app quitting and restarting I don't think there's a way to clear the static var in this case.

Re: Android externals getEngineApi issue

Posted: Thu Jul 17, 2014 12:03 am
by monte
OK, may as well replace all instances of getEngineApi with __InterfaceQueryEngine then.