Android externals getEngineApi issue

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, LCMark

Locked
monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1564
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Android externals getEngineApi issue

Post by monte » Wed Jul 09, 2014 4:42 am

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).
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1208
Joined: Thu Apr 11, 2013 11:27 am

Re: Android externals getEngineApi issue

Post by LCMark » Wed Jul 16, 2014 9:07 am

@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.

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1564
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: Android externals getEngineApi issue

Post by monte » Thu Jul 17, 2014 12:03 am

OK, may as well replace all instances of getEngineApi with __InterfaceQueryEngine then.
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

Locked

Return to “Engine Contributors”